home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-06 | 103.8 KB | 3,921 lines |
- // Filename: SERVICE.WMC
- // "DIB" Generated by Visual Programmer.
- // Author: Blue Sky
-
- //
- // ***********************************************************************
- // Do not add code here. Add code in the .CPP file.
- //
- // This file is maintained by the Switch-It Module.
- // As you make changes in your applications design,
- // this file is automatically updated, therefore you never modify this file.
- //
- //
- //
- // For more information,
- // see the section "How code is generated" in the documentation.
- //
- // ***********************************************************************
- //
-
-
- // ********************************************************
- // ERROR MESSAGE HANDLING
- // ********************************************************
-
- int BLDDisplayMessageDef(HWND hWnd,UINT uMsg,char *pContext,int iType)
- {
- int i, j;
- char szMessage[200+1];
-
- if (uMsg)
- {
- if (!LoadString(AfxGetResourceHandle(),uMsg,szMessage,200))
- {
- MessageBox(hWnd,BLDLOADERROR,BLDMAINCAPTION,
- MB_OK|MB_SYSTEMMODAL|MB_ICONHAND);
- return FALSE;
- }
- }
- else
- szMessage[0]=0;
-
- if (pContext)
- {
- i = lstrlen(szMessage);
- j = lstrlen(pContext);
- if (i + j + 1 <= 200)
- {
- lstrcat(szMessage, " ");
- lstrcat(szMessage, pContext);
- }
- }
-
- return MessageBox(hWnd,szMessage,BLDMAINCAPTION,iType);
- }
-
-
- // *************************************************************
- // FUNCTIONS FOR DRAWING GRAPHIC BUTTONS
- // *************************************************************
-
-
- BOOL BLDBitmapToScreenDef(HDC hDestDC, char *pBitmapName,
- int X,int Y,int nWidth,int nHeight,
- DWORD dwRop,BOOL bStretch)
- {
- HDC hMemDC;
- BITMAP Bitmap;
- HBITMAP hBitmap;
-
- if (!hBMPInst)
- hBMPInst = AfxGetResourceHandle();
-
- hBitmap = BLDLoadBitmap(hBMPInst,pBitmapName);
-
- if (!hBitmap)
- {
- BLDDisplayMessage(GetActiveWindow(),BLD_CannotLoadBitmap,pBitmapName,
- MB_OK | MB_ICONASTERISK);
- return FALSE;
- }
-
- hMemDC = CreateCompatibleDC(hDestDC);
-
- if (!hMemDC)
- {
- DeleteObject(hBitmap);
- return FALSE;
- }
- if (!SelectObject(hMemDC,hBitmap))
- {
- DeleteObject(hBitmap);
- DeleteDC(hMemDC);
- return FALSE;
- }
-
- if (bStretch)
- {
- if (!GetObject(hBitmap,sizeof(BITMAP),(LPSTR)&Bitmap))
- {
- DeleteObject(hBitmap);
- return FALSE;
- }
-
- StretchBlt(hDestDC,
- X,
- Y,
- nWidth,
- nHeight,
- hMemDC,
- 0,
- 0,
- Bitmap.bmWidth,
- Bitmap.bmHeight,
- dwRop);
- }
- else
- {
- BitBlt(hDestDC,X,Y,nWidth,nHeight,hMemDC,0,0,dwRop);
- }
-
- DeleteDC(hMemDC);
- DeleteObject(hBitmap);
- return TRUE;
- }
-
-
-
- BOOL BLDDrawIconDef(LPDRAWITEMSTRUCT lpDrawItem,char *pIconName)
- {
- HICON hIcon;
-
- hIcon = LoadIcon(AfxGetResourceHandle(),pIconName);
- if (!hIcon)
- {
- BLDDisplayMessage(GetActiveWindow(),BLD_CannotLoadIcon,pIconName,
- MB_OK | MB_ICONASTERISK);
- return FALSE;
- }
-
- SetMapMode(lpDrawItem->hDC,MM_TEXT);
- return DrawIcon(lpDrawItem->hDC,0,0,hIcon);
- }
-
-
-
- BOOL BLDDrawBitmapDef(LPDRAWITEMSTRUCT lpDrawItem,char *pBitmapName,BOOL bStretch)
- {
- int iRaster;
-
- iRaster = GetDeviceCaps(lpDrawItem->hDC,RASTERCAPS);
- if ((iRaster&RC_BITBLT)!=RC_BITBLT)
- return FALSE; // Device cannot display bitmap
-
- return BLDBitmapToScreen(lpDrawItem->hDC,pBitmapName,
- lpDrawItem->rcItem.left,
- lpDrawItem->rcItem.top,
- lpDrawItem->rcItem.right-lpDrawItem->rcItem.left,
- lpDrawItem->rcItem.bottom-lpDrawItem->rcItem.top,
- SRCCOPY,bStretch);
- }
-
-
-
- BOOL BLDDrawBkgndIconDef(HWND hDlg,LPPAINTSTRUCT pPs,char *pIconName,int iCtrlID)
- {
- RECT Rect,Dummy;
- HWND CtrlhWnd;
- HICON hIcon;
-
- CtrlhWnd=GetDlgItem(hDlg,iCtrlID);
- if(!CtrlhWnd)
- return FALSE;
- GetWindowRect(CtrlhWnd, &Rect);
- ScreenToClient(hDlg,(LPPOINT)&Rect.left);
- ScreenToClient(hDlg,(LPPOINT)&Rect.right);
-
- hIcon = LoadIcon(AfxGetResourceHandle(),pIconName);
- if (!hIcon)
- {
- BLDDisplayMessage(GetActiveWindow(),BLD_CannotLoadIcon,pIconName,
- MB_OK | MB_ICONASTERISK);
- return FALSE;
- }
-
- if(!IntersectRect(&Dummy, &Rect, &pPs->rcPaint))
- return TRUE; // No intersection
-
- SetMapMode(pPs->hdc,MM_TEXT);
- return DrawIcon(pPs->hdc,Rect.left,Rect.top,hIcon);
- }
-
-
-
- BOOL BLDDrawBkgndBitmapDef(HWND hDlg,LPPAINTSTRUCT pPs,char *pBitmapName,
- int iCtrlID,BOOL bStretch,BOOL bCtrl,int xScrolled,int yScrolled)
- {
- int iRaster;
- RECT Rect,Dummy;
- HWND CtrlhWnd;
-
- iRaster = GetDeviceCaps(pPs->hdc,RASTERCAPS);
- if ((iRaster&RC_BITBLT)!=RC_BITBLT)
- return FALSE; // Device cannot display bitmap
-
- if(bCtrl)
- {
- CtrlhWnd=GetDlgItem(hDlg,iCtrlID);
- if(!CtrlhWnd)
- return FALSE;
- GetWindowRect(CtrlhWnd, &Rect);
- ScreenToClient(hDlg,(LPPOINT)&Rect.left);
- ScreenToClient(hDlg,(LPPOINT)&Rect.right);
- }
- else
- {
- GetClientRect(hDlg, &Rect);
- if(!bStretch)
- {
- Rect.left -= xScrolled;
- Rect.top -= yScrolled;
- }
- }
-
- if(!IntersectRect(&Dummy, &Rect, &pPs->rcPaint))
- return TRUE; // No intersection
-
- return BLDBitmapToScreen(pPs->hdc,pBitmapName,
- Rect.left,
- Rect.top,
- Rect.right-Rect.left,
- Rect.bottom-Rect.top,
- SRCCOPY,bStretch);
- }
-
-
-
- BOOL BLDDrawAutoStateDef(LPDRAWITEMSTRUCT lpDrawItem,char *szResource,BOOL bBitmap,
- BOOL bStretch)
- {
- int x,y,dx,dy;
- BOOL bDown,bActive;
- HBRUSH hOldBrush;
- int incr,i,j,bGray;
- COLORREF color;
- HICON hIcon;
-
- if (lpDrawItem->CtlType != ODT_BUTTON)
- return FALSE;
-
- if ((lpDrawItem->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) == 0)
- return FALSE;
-
- bDown = (lpDrawItem->itemState & ODS_SELECTED) != 0;
- bActive = (lpDrawItem->itemState & ODS_DISABLED) == 0;
-
- x = lpDrawItem->rcItem.left;
- y = lpDrawItem->rcItem.top;
- dx = lpDrawItem->rcItem.right-lpDrawItem->rcItem.left-6;
- dy = lpDrawItem->rcItem.bottom-lpDrawItem->rcItem.top-6;
-
- incr = bDown ? 4 : 3;
-
- if(!*szResource)
- {
- hOldBrush = (HBRUSH)SelectObject(lpDrawItem->hDC,GetStockObject(LTGRAY_BRUSH));
- PatBlt(lpDrawItem->hDC, x+incr, y+incr, dx, dy, PATCOPY);
- SelectObject(lpDrawItem->hDC,hOldBrush);
- }
- else
- {
- if(bBitmap)
- {
- if(!BLDBitmapToScreen(lpDrawItem->hDC,szResource,
- x+incr,
- y+incr,
- dx,
- dy,
- SRCCOPY,bStretch))
- return FALSE;
- }
- else
- {
- hIcon=LoadIcon(AfxGetResourceHandle(),szResource);
- if (!hIcon)
- return FALSE;
- DrawIcon(lpDrawItem->hDC,x+incr,y+incr,hIcon);
- }
- }
-
- // Make the bitmap grayed
- if (!bActive)
- {
- color = BLD_LTGRAY;
-
- for (j=y+incr; j<dy; ++j)
- {
- bGray = j % 2;
- for (i=x+incr; i<dx; ++i)
- {
- if (bGray)
- SetPixel(lpDrawItem->hDC, i, j, color);
- bGray = !bGray;
- }
- }
- }
-
- return BLDDrawFrame(lpDrawItem->hDC,x,y,dx,dy,bDown);
- }
-
-
-
- BOOL BLDDrawStateBitmapDef(LPDRAWITEMSTRUCT lpDrawItem,char *szNormal,char *szFocus,
- char *szSelected,char *szDisabled,BOOL bStretch)
- {
- if( !*szFocus && !*szSelected && !*szDisabled)
- {
- return BLDDrawAutoState(lpDrawItem, szNormal, TRUE, bStretch);
- }
- if((lpDrawItem->itemState & ODS_DISABLED) && *szDisabled)
- return BLDDrawBitmap(lpDrawItem,szDisabled,bStretch);
- if((lpDrawItem->itemState & ODS_SELECTED) && *szSelected)
- return BLDDrawBitmap(lpDrawItem,szSelected,bStretch);
- if((lpDrawItem->itemState & ODS_FOCUS) && *szFocus)
- return BLDDrawBitmap(lpDrawItem,szFocus,bStretch);
- if(*szNormal)
- return BLDDrawBitmap(lpDrawItem,szNormal,bStretch);
- return TRUE;
- }
-
-
-
- BOOL BLDDrawStateIconDef(LPDRAWITEMSTRUCT lpDrawItem,char *szNormal,char *szFocus,
- char *szSelected,char *szDisabled)
- {
- if( !*szFocus && !*szSelected && !*szDisabled)
- {
- return BLDDrawAutoState(lpDrawItem, szNormal, FALSE, FALSE);
- }
- if((lpDrawItem->itemState & ODS_DISABLED) && *szDisabled)
- return BLDDrawIcon(lpDrawItem,szDisabled);
- if((lpDrawItem->itemState & ODS_SELECTED) && *szSelected)
- return BLDDrawIcon(lpDrawItem,szSelected);
- if((lpDrawItem->itemState & ODS_FOCUS) && *szFocus)
- return BLDDrawIcon(lpDrawItem,szFocus);
- if(*szNormal)
- return BLDDrawIcon(lpDrawItem,szNormal);
- return TRUE;
- }
-
-
-
- BOOL BLDDrawItemDef(HWND hDlg,LPDRAWITEMSTRUCT lpDrawItem)
- {
- char szStr[20];
-
- if(lpDrawItem->CtlType == ODT_BUTTON)
- {
- GetWindowText(lpDrawItem->hwndItem,szStr,20);
- if(lstrcmpi( (LPSTR)szStr, (LPSTR)"WMP3DBUTTON") == 0 )
- {
- BLDDrawStateBitmap(lpDrawItem,"","","","",TRUE);
- return TRUE;
- }
- }
- return FALSE;
- }
-
-
- BOOL BLDDrawFrame(HDC hDC,int x,int y,int dx,int dy,BOOL bDown)
- {
- HPEN hOld,hBlack,hLtGray,hGray,hWhite;
-
- hBlack = CreatePen(0,1,BLD_BLACK);
- hGray = CreatePen(0,1,GetDeviceCaps(hDC, NUMCOLORS) > 2 ? BLD_GRAY : BLD_WHITE);
- hWhite = CreatePen(0,1,BLD_WHITE);
- hLtGray = CreatePen(0,1,GetDeviceCaps(hDC, NUMCOLORS) > 2 ? BLD_LTGRAY : BLD_WHITE);
-
- // Paint the frame
- hOld = (HPEN)SelectObject(hDC, hBlack);
- BLDMoveTo(hDC,x+1,y);
- LineTo(hDC, x+dx+5, y);
- BLDMoveTo(hDC,x+1,y+dy+5);
- LineTo(hDC, x+dx+5, y+dy+5);
-
- BLDMoveTo(hDC,x,y+1);
- LineTo(hDC, x, y+dy+5);
- BLDMoveTo(hDC,x+dx+5,y+1);
- LineTo(hDC, x+dx+5, y+dy+5);
-
- if (bDown)
- {
- BLDMoveTo(hDC,x+1,y+1);
- LineTo(hDC, x+dx+5, y+1);
- BLDMoveTo(hDC,x+1,y+2);
- LineTo(hDC, x+1, y+dy+5);
- BLDMoveTo(hDC,x+dx+4,y+dy+4);
- LineTo(hDC, x, y+dy+4);
- BLDMoveTo(hDC,x+dx+4,y+dy+3);
- LineTo(hDC, x+dx+4, y);
-
- SelectObject(hDC,hGray);
- BLDMoveTo(hDC,x+2,y+2);
- LineTo(hDC,x+dx+4,y+2);
- BLDMoveTo(hDC,x+2,y+3);
- LineTo(hDC,x+2,y+dy+4);
-
- SelectObject(hDC,hLtGray);
- BLDMoveTo(hDC,x+3,y+3);
- LineTo(hDC,x+dx+4,y+3);
- BLDMoveTo(hDC,x+3,y+4);
- LineTo(hDC,x+3,y+dy+4);
- }
- else
- {
- SelectObject(hDC,hWhite);
- BLDMoveTo(hDC,x+1,y+1);
- LineTo(hDC,x+dx+4,y+1);
- BLDMoveTo(hDC,x+1,y+2);
- LineTo(hDC,x+1,y+dy+4);
- BLDMoveTo(hDC,x+2,y+2);
- LineTo(hDC,x+dx+3,y+2);
- BLDMoveTo(hDC,x+2,y+3);
- LineTo(hDC,x+2,y+dy+3);
-
-
- SelectObject(hDC, hGray);
- BLDMoveTo(hDC,x+dx+4,y+dy+4);
- LineTo(hDC,x,y+dy+4);
- BLDMoveTo(hDC,x+dx+4,y+dy+3);
- LineTo(hDC,x+dx+4,y);
- BLDMoveTo(hDC,x+dx+3,y+dy+3);
- LineTo(hDC,x+1,y+dy+3);
- BLDMoveTo(hDC,x+dx+3,y+dy+2);
- LineTo(hDC,x+dx+3,y+1);
- }
-
- SelectObject(hDC, hOld);
- DeleteObject(hBlack);
- DeleteObject(hWhite);
- DeleteObject(hGray);
- DeleteObject(hLtGray);
- return TRUE;
- }
-
-
- static BOOL BLDMoveTo(HDC hDC,int x,int y)
- {
- #ifdef WIN32
- return MoveToEx(hDC,x,y,NULL);
- #else
- return (BOOL)MoveTo(hDC,x,y);
- #endif
- }
-
-
- // *************************************************************
- // FUNCTIONS FOR DIALOG BOX SCROLLING
- // *************************************************************
-
- void BLDFindCtrlsRightBottomDef(CWnd *pWnd,int *xRight,int *yBottom)
- {
- CWnd *pCtrlhWnd;
- RECT Rect;
-
- *xRight=0;
- *yBottom=0;
-
- pCtrlhWnd = pWnd->GetWindow(GW_CHILD);
-
- while(pCtrlhWnd)
- {
- pCtrlhWnd->GetWindowRect(&Rect);
- pWnd->ScreenToClient((LPPOINT)&Rect.right);
- if(Rect.right > *xRight)
- *xRight = Rect.right;
- if(Rect.bottom > *yBottom)
- *yBottom = Rect.bottom;
- pCtrlhWnd = pCtrlhWnd->GetWindow(GW_HWNDNEXT);
- }
- }
-
-
- void BLDCalcScrollRangesDef(CWnd *pWnd,int *xRange,int *yRange,int xScrolled,
- int yScrolled,int iRightOf,int iBelow)
- {
- RECT ClientRect;
- int xRight,yBottom;
-
- BLDFindCtrlsRightBottom(pWnd,&xRight,&yBottom);
- pWnd->GetClientRect(&ClientRect);
- xRight +=xScrolled+iRightOf;
- yBottom+=yScrolled+iBelow;
-
- if(xRight - ClientRect.right > 0)
- *xRange=xRight - ClientRect.right;
- else
- *xRange=0;
- if(yBottom - ClientRect.bottom > 0)
- *yRange=yBottom - ClientRect.bottom;
- else
- *yRange=0;
- }
-
-
-
- BOOL BLDScrollDlgDef(CWnd *pWnd,UINT message,int nScrlCode,int nPos,int iVertLine,
- int iHorLine,int iVertPage,int iHorPage,int iRightOf,
- int iBelow,BOOL bInvalidate,int *pxScrolled,int *pyScrolled)
- {
- int xScroll,yScroll;
- int xRange,yRange;
- int iThumb;
- BOOL bDlgUnits;
-
-
- xScroll=yScroll=0;
-
- BLDCalcScrollRanges(pWnd,&xRange,&yRange,*pxScrolled,*pyScrolled,iRightOf,iBelow);
-
- bDlgUnits=FALSE;
- switch(message)
- {
- case WM_VSCROLL:
- switch(nScrlCode)
- {
- case SB_BOTTOM:
- yScroll=yRange-*pyScrolled;
- bDlgUnits=FALSE;
- break;
- case SB_ENDSCROLL:
- break;
- case SB_LINEDOWN:
- yScroll=iVertLine;
- bDlgUnits=TRUE;
- break;
- case SB_LINEUP:
- yScroll=-iVertLine;
- bDlgUnits=TRUE;
- break;
- case SB_PAGEDOWN:
- if(iVertPage)
- {
- RECT Rect;
- pWnd->GetClientRect(&Rect);
- yScroll=MulDiv(Rect.bottom,iVertPage,100);
- bDlgUnits=FALSE;
- }
- break;
- case SB_PAGEUP:
- if(iVertPage)
- {
- RECT Rect;
- pWnd->GetClientRect(&Rect);
- yScroll=-MulDiv(Rect.bottom,iVertPage,100);
- bDlgUnits=FALSE;
- }
- break;
- case SB_THUMBPOSITION:
- iThumb =nPos;
- yScroll=-*pyScrolled + MulDiv(iThumb,yRange,100);
- bDlgUnits=FALSE;
- break;
- case SB_THUMBTRACK: // No Support
- break;
- case SB_TOP:
- yScroll=-*pyScrolled;
- bDlgUnits=FALSE;
- break;
- }
- break;
- case WM_HSCROLL:
- switch(nScrlCode)
- {
- case SB_BOTTOM:
- xScroll=xRange-*pxScrolled;
- bDlgUnits=FALSE;
- break;
- case SB_ENDSCROLL:
- break;
- case SB_LINEDOWN:
- xScroll=iHorLine;
- bDlgUnits=TRUE;
- break;
- case SB_LINEUP:
- xScroll=-iHorLine;
- bDlgUnits=TRUE;
- break;
- case SB_PAGEDOWN:
- if(iVertPage)
- {
- RECT Rect;
- pWnd->GetClientRect(&Rect);
- xScroll=MulDiv(Rect.right,iHorPage,100);
- bDlgUnits=FALSE;
- }
- break;
- case SB_PAGEUP:
- if(iVertPage)
- {
- RECT Rect;
- pWnd->GetClientRect(&Rect);
- xScroll=-MulDiv(Rect.bottom,iHorPage,100);
- bDlgUnits=FALSE;
- }
- break;
- case SB_THUMBPOSITION:
- iThumb =nPos;
- xScroll=-*pxScrolled + MulDiv(iThumb,xRange,100);
- bDlgUnits=FALSE;
- break;
- case SB_THUMBTRACK: // No Support
- break;
- case SB_TOP:
- xScroll=-*pxScrolled;
- bDlgUnits=FALSE;
- break;
- }
- break;
- }
-
- if(xScroll || yScroll)
- {
- int x,y;
- int oldx,oldy;
-
- x=y=0;
- if(bDlgUnits)
- {
- BOOL xNeg,yNeg;
- xNeg=yNeg=FALSE;
- if(xScroll < 0)
- {
- xScroll=-xScroll;
- xNeg=TRUE;
- }
- if(yScroll < 0)
- {
- yScroll=-yScroll;
- yNeg=TRUE;
- }
- xScroll=(xScroll * LOWORD(GetDialogBaseUnits()))/4;
- yScroll=(yScroll * HIWORD(GetDialogBaseUnits()))/8;
- if(xNeg)
- xScroll=-xScroll;
- if(yNeg)
- yScroll=-yScroll;
- }
-
- oldx=*pxScrolled;
- oldy=*pyScrolled;
- *pxScrolled+=xScroll;
- *pyScrolled+=yScroll;
-
- if(*pxScrolled > xRange)
- *pxScrolled = xRange;
- if(*pxScrolled < 0)
- *pxScrolled=0;
-
- if(*pyScrolled > yRange)
- *pyScrolled = yRange;
- if(*pyScrolled < 0)
- *pyScrolled=0;
-
- xScroll=*pxScrolled - oldx;
- yScroll=*pyScrolled - oldy;
-
- if(xScroll || yScroll)
- {
- pWnd->ScrollWindow(-xScroll,-yScroll,NULL,NULL);
- if(xRange)
- {
- x=MulDiv(*pxScrolled,100,xRange);
- pWnd->SetScrollPos(SB_HORZ,x,TRUE);
- }
- if(yRange)
- {
- y=MulDiv(*pyScrolled,100,yRange);
- pWnd->SetScrollPos(SB_VERT,y,TRUE);
- }
- if(bInvalidate)
- pWnd->InvalidateRect(NULL,FALSE);
- }
- }
- return TRUE;
- }
-
-
- // *************************************************************
- // FUNCTION FOR CREATING CONTROLS IN MAIN WINDOW
- // *************************************************************
-
- // Supports Controls in Main window from old versions
- BOOL BLDCreateClientControlsDef(char *pTemplateName, CSimClientDlg* pDlg)
- {
-
- pDlg->SimSetTemplate(pTemplateName); //Set template. Constructor
- //without parameters was used
- //in earlier versions in .cpp file
- if (pDlg->Create(TheApp.m_pMainWnd))
- {
- TheApp.pWndClient = pDlg;
- return TRUE;
- }
- else
- return FALSE;
- }
-
-
- // *************************************************************
- // FUNCTION SENDING MDI MESSAGES
- // *************************************************************
-
- BOOL BLDSendMDIMessageDef(CWnd *pWnd,UINT message,int nType)
- {
- if(TheApp.m_pMainWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd)))
- {
- CMDIFrameWnd *pMDIFrameWnd = (CMDIFrameWnd *)TheApp.m_pMainWnd;
- CMDIChildWnd *pCMDIChildWnd;
- switch(message)
- {
- case WM_MDICASCADE:
- #if (WINVER >= 0x030a)
- pMDIFrameWnd->MDICascade(nType);
- #else
- pMDIFrameWnd->MDICascade();
- #endif
- break;
- case WM_MDITILE:
- #if (WINVER >= 0x030a)
- pMDIFrameWnd->MDITile(nType);
- #else
- pMDIFrameWnd->MDITile();
- #endif
- break;
- case WM_MDIICONARRANGE:
- pMDIFrameWnd->MDIIconArrange();
- break;
- case WM_MDIGETACTIVE:
- pCMDIChildWnd = pMDIFrameWnd->MDIGetActive();
- if(pCMDIChildWnd)
- pCMDIChildWnd->MDIDestroy();
- break;
- default:
- return FALSE;
- }
- return TRUE;
- }
- return FALSE; //Not an MDI application
- }
-
-
- // *************************************************************
- // FUNCTION EXPANDING OF DIALOG BOX
- // *************************************************************
-
- BOOL BLDSizeDlgDef(CWnd *pWnd,int xRightOf,int yBelow)
- {
- return (BOOL)pWnd->SendMessage(wPrivateMessage,SIM_SIZEDIALOG,
- MAKELONG(xRightOf,yBelow));
- }
-
-
- // *************************************************************
- // FUNCTIONS FOR HELP HANDLING
- // *************************************************************
-
-
- BOOL BLDCheckF1HelpKeyDef(BOOL bShift)
- {
- if(GetKeyState(VK_F1) >= 0)
- return FALSE;
- if(bShift)
- {
- if(GetKeyState(VK_SHIFT) >= 0)
- return FALSE;
- }
- else
- {
- if(GetKeyState(VK_SHIFT) < 0)
- return FALSE;
- }
- if(GetKeyState(VK_CONTROL) < 0)
- return FALSE;
- if(GetKeyState(VK_MENU) < 0)
- return FALSE;
- return TRUE;
- }
-
-
- HBRUSH BLDGetGlobalBrushDef(HWND hCtrl,HDC hDC)
- {
- char szClass[21];
- static HBRUSH hGray = 0;
-
- if (!hCtrl)
- return 0;
-
- if (!hGray)
- hGray = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
-
- if (!GetClassName(hCtrl,szClass,20))
- return 0;
-
- if (lstrcmpi(szClass,"EDIT")==0)
- {
- if (dwDialogProp&BLDGRAY_EDIT)
- goto RETGRAYBRUSH;
- else
- return 0;
- }
- if (lstrcmpi(szClass,"COMBOBOX")==0)
- {
- if (dwDialogProp&BLDGRAY_COMBOBOX)
- goto RETGRAYBRUSH;
- else
- return 0;
- }
- if (lstrcmpi(szClass,"LISTBOX")==0)
- {
- if (dwDialogProp&BLDGRAY_LISTBOX)
- goto RETGRAYBRUSH;
- else
- return 0;
- }
- if (lstrcmpi(szClass,"BUTTON")==0)
- {
- if ((dwDialogProp&BLDGRAY_BUTTON))
- goto RETGRAYBRUSH;
- else
- return 0;
- }
- if (lstrcmpi(szClass,"SCROLLBAR")==0)
- {
- if (dwDialogProp&BLDGRAY_SCROLLBAR)
- goto RETGRAYBRUSH;
- else
- return 0;
- }
- if (lstrcmpi(szClass,"STATIC")==0)
- {
- if (dwDialogProp&BLDGRAY_TEXT)
- goto RETGRAYBRUSH;
- else
- return 0;
- }
-
- return 0;
-
- RETGRAYBRUSH:
- if (hDC)
- SetBkColor(hDC,RGB(192,192,192));
- return hGray;
- }
-
-
-
- // *************************************************************
- // Member Functions for MODAL dialog : CSimModalDlg
- // Base Class : CDialog
- // *************************************************************
-
- CSimModalDlg::CSimModalDlg(LPCSTR lpszTemplateName,CWnd *pParentWnd)
- : CDialog(lpszTemplateName,pParentWnd)
- {
- ms_bDeleteBrush=ms_bScrollSupport=FALSE;
- ms_hBrush=0;
- ms_szBitmap=NULL;
- ms_bAutoMenuEnable=TRUE; // auto enable on by default
- }
-
-
-
- CSimModalDlg::~CSimModalDlg()
- {
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- if(ms_szBitmap)
- delete ms_szBitmap;
- }
-
-
-
- LRESULT CSimModalDlg::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- RECT Rect;
- RECT OldWindowRect;
- RECT NewActualClientRect;
- int Cx,Cy,xMax,yMax;
-
- if(wParam != SIM_SIZEDIALOG)
- return FALSE;
-
- BLDFindCtrlsRightBottom(this,&Cx,&Cy);
-
- Cx += LOWORD(lParam);
- Cy += HIWORD(lParam);
-
- GetClientRect((LPRECT)&Rect);
- if (Rect.right >= Cx && Rect.bottom >= Cy )
- return TRUE;
-
- if(Rect.right < Cx)
- Rect.right = Cx;
- if(Rect.bottom < Cy)
- Rect.bottom = Cy;
-
- GetWindowRect(&OldWindowRect);
-
- if(!(GetStyle() & WS_CHILD))
- ClientToScreen((LPPOINT)&Rect.left);
- else
- GetParent()->ScreenToClient((LPPOINT)&OldWindowRect.left);
-
- Rect.right +=Rect.left;
- Rect.bottom+=Rect.top;
-
- AdjustWindowRectEx(&Rect,GetStyle(),GetMenu() ? TRUE : FALSE,
- GetExStyle());
-
- if(OldWindowRect.top != Rect.top)
- {
- Rect.bottom += OldWindowRect.top - Rect.top;
- Rect.top =OldWindowRect.top;
- }
- if(OldWindowRect.left != Rect.left)
- {
- Rect.right += OldWindowRect.left - Rect.left;
- Rect.left =OldWindowRect.left;
- }
-
- xMax = GetSystemMetrics(SM_CXSCREEN);
- yMax = GetSystemMetrics(SM_CYSCREEN);
- if ((Rect.right-Rect.left<=xMax)&&(Rect.right>xMax))
- Rect.left=xMax-(Rect.right-Rect.left);
- if ((Rect.bottom-Rect.top<=yMax)&&(Rect.bottom>yMax))
- Rect.top=yMax-(Rect.bottom-Rect.top);
-
- MoveWindow(Rect.left,Rect.top,Rect.right-Rect.left,
- Rect.bottom-Rect.top,TRUE);
- GetClientRect(&NewActualClientRect);
-
- if(NewActualClientRect.bottom != Cy)
- {
- Rect.bottom -= NewActualClientRect.bottom - Cy;
- MoveWindow(Rect.left,Rect.top,Rect.right-Rect.left,
- Rect.bottom-Rect.top,TRUE);
- }
- if(NewActualClientRect.right != Cx)
- {
- Rect.right -= NewActualClientRect.right - Cx;
- MoveWindow(Rect.left,Rect.top,Rect.right-Rect.left,
- Rect.bottom-Rect.top,TRUE);
- }
-
- return TRUE;
-
- }
-
-
-
- LRESULT CSimModalDlg::OnCommandHelp(WPARAM wParam, LPARAM lParam)
- {
- if(ms_HelpID)
- {
- TheApp.WinHelp(ms_HelpID);
- return TRUE;
- }
- return CDialog::OnCommandHelp(wParam,lParam);
- }
-
-
-
- BOOL CSimModalDlg::OnCommand(WPARAM wParam, LPARAM lParam)
- {
- if(TheApp.m_bHelpMode)
- {
- if(!(UINT)lParam)
- {
- if(TheApp.MenuHelp(wParam))
- return TRUE;
- }
- TheApp.WinHelp(ms_HelpID);
- return TRUE;
- }
- return CDialog::OnCommand( wParam, lParam);
- }
-
-
-
- BOOL CSimModalDlg::OnSetCursor (CWnd* pWnd, UINT nHitTest, UINT message)
- {
- if(TheApp.m_bHelpMode)
- {
- ::SetCursor(TheApp.m_hcurHelp);
- return TRUE;
- }
- return CDialog::OnSetCursor (pWnd, nHitTest, message);
- }
-
-
-
- void CSimModalDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_VSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimModalDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_HSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimModalDlg::OnPaint()
- {
- PAINTSTRUCT ps;
- HWND hWnd;
-
- if(!GetUpdateRect((LPRECT)NULL))
- return;
- if(!BeginPaint((LPPAINTSTRUCT)&ps))
- return;
-
- if(ms_szBitmap)
- ::BLDDrawBkgndBitmap(GetSafeHwnd(),(LPPAINTSTRUCT)&ps,ms_szBitmap,0,ms_bStretch,FALSE,ms_xScrolled,ms_yScrolled);
-
- // we use 'HWND's to avoid generation of too many temporary CWnds
- hWnd=::GetWindow(GetSafeHwnd(),GW_CHILD);
-
- while(hWnd)
- {
- ::SendMessage(hWnd,wPrivateMessage,SIM_CTRLPAINT,
- (LONG)(LPPAINTSTRUCT)&ps);
- hWnd=::GetWindow(hWnd,GW_HWNDNEXT);
- }
-
- EndPaint((LPPAINTSTRUCT)&ps);
- }
-
-
-
- HBRUSH CSimModalDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
-
- if(nCtlColor == CTLCOLOR_DLG)
- {
- if(ms_hBrush)
- {
- int x,y,xScrl,yScrl;
- #ifdef WIN32
- POINT p;
- #else
- CPoint p;
- #endif
-
- if(ms_bScrollSupport)
- {
- yScrl = ms_yScrolled;
- xScrl = ms_xScrolled;
- }
- else
- yScrl=yScrl=0;
- UnrealizeObject(ms_hBrush);
-
- #ifdef WIN32
- ::GetBrushOrgEx(pDC->GetSafeHdc(),&p);
- x=p.x;
- y=p.y;
- #else
- p=pDC->GetBrushOrg();
- x=p.x;
- y=p.y;
- #endif
-
- xScrl=-xScrl+x;
- yScrl=-yScrl+y;
- #ifdef WIN32
- ::SetBrushOrgEx(pDC->GetSafeHdc(),xScrl,yScrl,NULL);
- #else
- pDC->SetBrushOrg(xScrl,yScrl);
- #endif
- ::SelectObject(pDC->GetSafeHdc(),ms_hBrush);//Assertion failed
- //when using pDC->SelectObject
- return ms_hBrush;
- }
- }
- else
- {
- HBRUSH hBrushret;
- #ifdef WIN32
- hBrushret=(HBRUSH)pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,(LPARAM)pDC->m_hDC);
- #else
- hBrushret=(HBRUSH)LOWORD(pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,MAKELONG(pDC->m_hDC,0)));
- #endif
- if(hBrushret)
- return hBrushret;
- }
- if(dwDialogProp&BLDGRAY_DIALOGBOX)
- {
- switch (nCtlColor)
- {
- case CTLCOLOR_LISTBOX:
- case CTLCOLOR_MSGBOX:
- {
- HBRUSH hBrushret;
- hBrushret=BLDGetGlobalBrushDef(pWnd->GetSafeHwnd(),pDC->GetSafeHdc());
- if(hBrushret)
- return hBrushret;
- else
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- }
- break;
- case CTLCOLOR_EDIT:
- if (!(dwDialogProp&BLDGRAY_EDIT))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_BTN:
- if (!(dwDialogProp&BLDGRAY_BUTTON))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_SCROLLBAR:
- if (!(dwDialogProp&BLDGRAY_SCROLLBAR))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_STATIC:
- if (!(dwDialogProp&BLDGRAY_TEXT))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_DLG:
- break;
- default:
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- }
- pDC->SetBkColor(RGB(192,192,192));
- return (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- }
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- }
-
-
-
- //For default processing of WM_DRAWITEM
- LRESULT CSimModalDlg::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
- {
- if(nMsg == WM_DRAWITEM)
- {
- char szStr[20];
- LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
- if(lpDrawItem->CtlType == ODT_BUTTON)
- {
- ::GetWindowText(lpDrawItem->hwndItem,szStr,20);
- if(lstrcmpi( (LPSTR)szStr, (LPSTR)"WMP3DBUTTON") == 0 )
- {
- BLDDrawStateBitmap(lpDrawItem,"","","","",TRUE);
- return TRUE;
- }
- }
- }
- return CDialog::DefWindowProc(nMsg,wParam,lParam);
- }
-
-
-
- //To support menues in dialogboxes
- BOOL CSimModalDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo)
- {
- //Control command handling ?
- if (CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- // if not, pump through app
- CWinApp* pApp = AfxGetApp();
- if (pApp != NULL &&
- pApp->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- return FALSE;
- }
-
-
- //This function is from MFC source for class 'CFrameWnd' to
- //support enabling and disabling of menuitems in dialogboxes
- void CSimModalDlg::OnInitMenuPopup(CMenu* pMenu, UINT, BOOL bSysMenu)
- {
-
- if (bSysMenu)
- return; // don't support system menu
-
- if(pMenu == NULL)
- return;
-
- // check the enabled state of various menu items
- CCmdUI state;
- state.m_pMenu = pMenu;
-
- state.m_nIndexMax = pMenu->GetMenuItemCount();
- for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
- state.m_nIndex++)
- {
- state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
- if (state.m_nID == 0)
- continue; // menu separator or invalid cmd - ignore it
-
- if (state.m_nID == (UINT)-1)
- {
- // possibly a popup menu, route to first item of that popup
- state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
- if (state.m_pSubMenu == NULL ||
- (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
- state.m_nID == (UINT)-1)
- {
- continue; // first item of popup can't be routed to
- }
- state.DoUpdate(this, FALSE); // popups are never auto disabled
- }
- else
- {
- // normal menu item
- // Auto enable/disable if frame window has 'm_bAutoMenuEnable'
- // set and command is _not_ a system command.
- state.m_pSubMenu = NULL;
- state.DoUpdate(this, ms_bAutoMenuEnable && state.m_nID < 0xF000);
- }
- }
- }
-
-
-
- LRESULT CSimModalDlg::OnHelpHitTest(WPARAM wParam, LPARAM lParam)
- {
- if(ms_HelpID)
- return ms_HelpID;
- return CSimModalDlg::OnHelpHitTest(wParam, lParam);
- }
-
-
-
- IMPLEMENT_DYNCREATE(CSimModalDlg, CDialog)
-
- BEGIN_MESSAGE_MAP(CSimModalDlg, CDialog)
-
- ON_WM_CTLCOLOR()
- ON_WM_PAINT()
- ON_WM_HSCROLL()
- ON_WM_VSCROLL()
- ON_WM_INITMENUPOPUP()
- ON_MESSAGE(WM_HELPHITTEST, OnHelpHitTest)
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
- ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
- ON_WM_SETCURSOR()
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member Functions for MODELESS dialog : CSimModelessDlg
- // Base Class : CDialog
- // *************************************************************
-
- CSimModelessDlg::CSimModelessDlg()
- : CDialog()
- {
- ms_bDeleteBrush=ms_bScrollSupport=FALSE;
- ms_hBrush=0;
- ms_szBitmap=NULL;
- ms_bAutoMenuEnable=TRUE; // auto enable on by default
- }
-
-
-
- CSimModelessDlg::~CSimModelessDlg()
- {
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- if(ms_szBitmap)
- delete ms_szBitmap;
- }
-
-
-
- void CSimModelessDlg::PostNcDestroy()
- {
- delete this;
- }
-
-
-
- void CSimModelessDlg::OnOK()
- {
- if (UpdateData(TRUE))
- DestroyWindow();
- }
-
-
-
- void CSimModelessDlg::OnCancel()
- {
- DestroyWindow();
- }
-
-
-
- LRESULT CSimModelessDlg::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- RECT Rect;
- RECT OldWindowRect;
- RECT NewActualClientRect;
- int Cx,Cy,xMax,yMax;
-
- if(wParam != SIM_SIZEDIALOG)
- return FALSE;
-
- BLDFindCtrlsRightBottom(this,&Cx,&Cy);
-
- Cx += LOWORD(lParam);
- Cy += HIWORD(lParam);
-
- GetClientRect((LPRECT)&Rect);
- if (Rect.right >= Cx && Rect.bottom >= Cy )
- return TRUE;
-
- if(Rect.right < Cx)
- Rect.right = Cx;
- if(Rect.bottom < Cy)
- Rect.bottom = Cy;
-
- GetWindowRect(&OldWindowRect);
-
- if(!(GetStyle() & WS_CHILD))
- ClientToScreen((LPPOINT)&Rect.left);
- else
- GetParent()->ScreenToClient((LPPOINT)&OldWindowRect.left);
-
- Rect.right +=Rect.left;
- Rect.bottom+=Rect.top;
-
- AdjustWindowRectEx(&Rect,GetStyle(),GetMenu() ? TRUE : FALSE,
- GetExStyle());
-
- if(OldWindowRect.top != Rect.top)
- {
- Rect.bottom += OldWindowRect.top - Rect.top;
- Rect.top =OldWindowRect.top;
- }
- if(OldWindowRect.left != Rect.left)
- {
- Rect.right += OldWindowRect.left - Rect.left;
- Rect.left =OldWindowRect.left;
- }
-
- xMax = GetSystemMetrics(SM_CXSCREEN);
- yMax = GetSystemMetrics(SM_CYSCREEN);
- if ((Rect.right-Rect.left<=xMax)&&(Rect.right>xMax))
- Rect.left=xMax-(Rect.right-Rect.left);
- if ((Rect.bottom-Rect.top<=yMax)&&(Rect.bottom>yMax))
- Rect.top=yMax-(Rect.bottom-Rect.top);
-
- MoveWindow(Rect.left,Rect.top,Rect.right-Rect.left,
- Rect.bottom-Rect.top,TRUE);
- GetClientRect(&NewActualClientRect);
-
- if(NewActualClientRect.bottom != Cy)
- {
- Rect.bottom -= NewActualClientRect.bottom - Cy;
- MoveWindow(Rect.left,Rect.top,Rect.right-Rect.left,
- Rect.bottom-Rect.top,TRUE);
- }
- if(NewActualClientRect.right != Cx)
- {
- Rect.right -= NewActualClientRect.right - Cx;
- MoveWindow(Rect.left,Rect.top,Rect.right-Rect.left,
- Rect.bottom-Rect.top,TRUE);
- }
-
- return TRUE;
-
- }
-
-
-
- LRESULT CSimModelessDlg::OnCommandHelp(WPARAM wParam, LPARAM lParam)
- {
- if(ms_HelpID)
- {
- TheApp.WinHelp(ms_HelpID);
- return TRUE;
- }
- return CDialog::OnCommandHelp(wParam,lParam);
- }
-
-
-
- BOOL CSimModelessDlg::OnCommand(WPARAM wParam, LPARAM lParam)
- {
- if(TheApp.m_bHelpMode)
- {
- if(!(UINT)lParam)
- {
- if(TheApp.MenuHelp(wParam))
- return TRUE;
- }
- TheApp.WinHelp(ms_HelpID);
- return TRUE;
- }
- return CDialog::OnCommand( wParam, lParam);
- }
-
-
-
- BOOL CSimModelessDlg::OnSetCursor (CWnd* pWnd, UINT nHitTest, UINT message)
- {
- if(TheApp.m_bHelpMode)
- {
- ::SetCursor(TheApp.m_hcurHelp);
- return TRUE;
- }
- return CDialog::OnSetCursor (pWnd, nHitTest, message);
- }
-
-
-
- void CSimModelessDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_VSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimModelessDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_HSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimModelessDlg::OnPaint()
- {
- PAINTSTRUCT ps;
- HWND hWnd;
-
- if(!GetUpdateRect((LPRECT)NULL))
- return;
- if(!BeginPaint((LPPAINTSTRUCT)&ps))
- return;
-
- if(ms_szBitmap)
- ::BLDDrawBkgndBitmap(GetSafeHwnd(),(LPPAINTSTRUCT)&ps,ms_szBitmap,0,ms_bStretch,FALSE,ms_xScrolled,ms_yScrolled);
-
- // we use 'HWND's to avoid generation of too many temporary CWnds
- hWnd=::GetWindow(GetSafeHwnd(),GW_CHILD);
-
- while(hWnd)
- {
- ::SendMessage(hWnd,wPrivateMessage,SIM_CTRLPAINT,
- (LONG)(LPPAINTSTRUCT)&ps);
- hWnd=::GetWindow(hWnd,GW_HWNDNEXT);
- }
-
- EndPaint((LPPAINTSTRUCT)&ps);
- }
-
-
-
- HBRUSH CSimModelessDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
-
- if(nCtlColor == CTLCOLOR_DLG)
- {
- if(ms_hBrush)
- {
- int x,y,xScrl,yScrl;
- #ifdef WIN32
- POINT p;
- #else
- CPoint p;
- #endif
-
- if(ms_bScrollSupport)
- {
- yScrl = ms_yScrolled;
- xScrl = ms_xScrolled;
- }
- else
- yScrl=yScrl=0;
- UnrealizeObject(ms_hBrush);
-
- #ifdef WIN32
- ::GetBrushOrgEx(pDC->GetSafeHdc(),&p);
- x=p.x;
- y=p.y;
- #else
- p=pDC->GetBrushOrg();
- x=p.x;
- y=p.y;
- #endif
-
- xScrl=-xScrl+x;
- yScrl=-yScrl+y;
- #ifdef WIN32
- ::SetBrushOrgEx(pDC->GetSafeHdc(),xScrl,yScrl,NULL);
- #else
- pDC->SetBrushOrg(xScrl,yScrl);
- #endif
- ::SelectObject(pDC->GetSafeHdc(),ms_hBrush);//Assertion failed
- //when using pDC->SelectObject
- return ms_hBrush;
- }
- }
- else
- {
- HBRUSH hBrushret;
- #ifdef WIN32
- hBrushret=(HBRUSH)pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,(LPARAM)pDC->m_hDC);
- #else
- hBrushret=(HBRUSH)LOWORD(pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,MAKELONG(pDC->m_hDC,0)));
- #endif
- if(hBrushret)
- return hBrushret;
- }
- if(dwDialogProp&BLDGRAY_DIALOGBOX)
- {
- switch (nCtlColor)
- {
- case CTLCOLOR_LISTBOX:
- case CTLCOLOR_MSGBOX:
- {
- HBRUSH hBrushret;
- hBrushret=BLDGetGlobalBrushDef(pWnd->GetSafeHwnd(),pDC->GetSafeHdc());
- if(hBrushret)
- return hBrushret;
- else
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- }
- break;
- case CTLCOLOR_EDIT:
- if (!(dwDialogProp&BLDGRAY_EDIT))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_BTN:
- if (!(dwDialogProp&BLDGRAY_BUTTON))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_SCROLLBAR:
- if (!(dwDialogProp&BLDGRAY_SCROLLBAR))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_STATIC:
- if (!(dwDialogProp&BLDGRAY_TEXT))
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_DLG:
- break;
- default:
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- }
- pDC->SetBkColor(RGB(192,192,192));
- return (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- }
- return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
- }
-
-
-
- //For default processing of WM_DRAWITEM
- LRESULT CSimModelessDlg::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
- {
- if(nMsg == WM_DRAWITEM)
- {
- char szStr[20];
- LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
- if(lpDrawItem->CtlType == ODT_BUTTON)
- {
- ::GetWindowText(lpDrawItem->hwndItem,szStr,20);
- if(lstrcmpi( (LPSTR)szStr, (LPSTR)"WMP3DBUTTON") == 0 )
- {
- BLDDrawStateBitmap(lpDrawItem,"","","","",TRUE);
- return TRUE;
- }
- }
- }
- return CDialog::DefWindowProc(nMsg,wParam,lParam);
- }
-
-
-
- //To support menues in dialogboxes
- BOOL CSimModelessDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo)
- {
- //Control command handling ?
- if (CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- // if not, pump through app
- CWinApp* pApp = AfxGetApp();
- if (pApp != NULL &&
- pApp->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- return FALSE;
- }
-
-
- //This function is from MFC source for class 'CFrameWnd' to
- //support enabling and disabling of menuitems in dialogboxes
- void CSimModelessDlg::OnInitMenuPopup(CMenu* pMenu, UINT, BOOL bSysMenu)
- {
-
- if (bSysMenu)
- return; // don't support system menu
-
- if(pMenu == NULL)
- return;
-
- // check the enabled state of various menu items
- CCmdUI state;
- state.m_pMenu = pMenu;
-
- state.m_nIndexMax = pMenu->GetMenuItemCount();
- for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
- state.m_nIndex++)
- {
- state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
- if (state.m_nID == 0)
- continue; // menu separator or invalid cmd - ignore it
-
- if (state.m_nID == (UINT)-1)
- {
- // possibly a popup menu, route to first item of that popup
- state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
- if (state.m_pSubMenu == NULL ||
- (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
- state.m_nID == (UINT)-1)
- {
- continue; // first item of popup can't be routed to
- }
- state.DoUpdate(this, FALSE); // popups are never auto disabled
- }
- else
- {
- // normal menu item
- // Auto enable/disable if frame window has 'm_bAutoMenuEnable'
- // set and command is _not_ a system command.
- state.m_pSubMenu = NULL;
- state.DoUpdate(this, ms_bAutoMenuEnable && state.m_nID < 0xF000);
- }
- }
- }
-
-
-
- LRESULT CSimModelessDlg::OnHelpHitTest(WPARAM wParam, LPARAM lParam)
- {
- if(ms_HelpID)
- return ms_HelpID;
- return CSimModelessDlg::OnHelpHitTest(wParam, lParam);
- }
-
-
-
- IMPLEMENT_DYNCREATE(CSimModelessDlg, CDialog)
-
- BEGIN_MESSAGE_MAP(CSimModelessDlg, CDialog)
-
- ON_WM_CTLCOLOR()
- ON_WM_PAINT()
- ON_WM_HSCROLL()
- ON_WM_VSCROLL()
- ON_WM_INITMENUPOPUP()
- ON_MESSAGE(WM_HELPHITTEST, OnHelpHitTest)
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
- ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
- ON_WM_SETCURSOR()
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member Functions for Toolbars : CSimToolbar
- // Base Class : CDialogBar
- // *************************************************************
-
- CSimToolbar::CSimToolbar()
- : CDialogBar()
- {
- ms_bDeleteBrush=ms_bScrollSupport=FALSE;
- ms_hBrush=0;
- ms_szBitmap=NULL;
- ms_nThisStyle=0;
- }
-
-
-
- CSimToolbar::~CSimToolbar()
- {
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- if(ms_szBitmap)
- delete ms_szBitmap;
- }
-
-
-
- void CSimToolbar::OnNcDestroy()
- {
- CWnd* pParentWnd = GetParent();
- BLDSetChildDialog SetChildDialog;
- SetChildDialog.pWnd =0;
- SetChildDialog.nStyle=ms_nThisStyle;
- if(pParentWnd)
- pParentWnd->SendMessage(wPrivateMessage,SIM_SETCHILDDIALOG,(LONG)(LPBLDSetChildDialog)&SetChildDialog);
- CDialogBar::OnNcDestroy();
- }
-
-
-
-
-
- int CSimToolbar::OnCreate(LPCREATESTRUCT lpcs)
- {
- //OnCreate is declared in MFC's class CControlBar but not implemented.
- //This functions is added here to avoid link error if
- //WM_CREATE message is processed
- return 0;
- }
-
-
- //Prepares dialog template resource before calling
- //CDialogBar::Create().
- //This function removes unwanted styles in the template before it calls
- //CDialogBar::Create which will fail if the style includes WS_VISIBLE
- //and not includes WS_CHILD
-
- BOOL CSimToolbar::Create(CWnd* pParentWnd, LPCSTR lpszTemplateName,
- UINT nStyle, UINT nID)
- {
- CSize m_sizeFixedLayoutOld; //Size of old toolbar if any
-
- //Find parent of type CFrameWnd or derived class.
- if(!pParentWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)))
- {
- pParentWnd = pParentWnd->GetParent();
- while (pParentWnd != NULL)
- {
- if (pParentWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)))
- break;
- pParentWnd = pParentWnd->GetParent();
- }
- }
- if(!pParentWnd)
- {
- return FALSE;
- }
- //Remove old toolbar with same style if any
- CSimToolbar* pOld=(CSimToolbar*)pParentWnd->SendMessage(wPrivateMessage,SIM_GETCHILDDIALOG,MAKELONG(nStyle,0));
- if(pOld)
- {
- m_sizeFixedLayoutOld = pOld->m_sizeFixedLayout;
- pOld->DestroyWindow();
- }
- else
- m_sizeFixedLayoutOld.cx=m_sizeFixedLayoutOld.cy=0;
-
- m_bAutoDelete=TRUE; //Delete CSimToolbar object when window is destroyed
-
- HRSRC hResource = ::FindResource(AfxGetResourceHandle(), lpszTemplateName, RT_DIALOG);
- if (hResource == NULL)
- {
- return FALSE;
- }
-
- HGLOBAL hTemplate = ::LoadResource(AfxGetResourceHandle(), hResource);
- if (hTemplate == NULL)
- {
- return FALSE;
- }
- // style is first DWORD in resource
- void FAR * lpResource =::LockResource(hTemplate);
-
- DWORD dwOldStyle = *(DWORD FAR*)lpResource;
-
- DWORD tmpdwStyle = dwOldStyle&(TOOLBARSTRIP);
- DWORD dwStyle = dwOldStyle^tmpdwStyle;
- dwStyle = dwStyle | WS_CHILD | WS_CLIPSIBLINGS;
-
- *(DWORD FAR*)lpResource= dwStyle; //Set new style dialog template
- BOOL retval = CDialogBar::Create(pParentWnd,lpszTemplateName,nStyle,nID);
-
- *(DWORD FAR*)lpResource= dwOldStyle; //Reset style
-
- #ifdef WIN32
- // It is not necessary for Win32 applications to unlock resources.
- #else
- ::UnlockResource(hTemplate);
- #endif
-
- ::FreeResource(hTemplate);
-
- if(retval) //There is no OnInitDialog() in base MFC class CDialogBar
- OnInitDialog(); //so we have to invoke it directly
-
- ms_nThisStyle = nStyle;
-
- //Make parent aware of this child window
- BLDSetChildDialog SetChildDialog;
- SetChildDialog.pWnd =this;
- SetChildDialog.nStyle=ms_nThisStyle;
- pParentWnd->SendMessage(wPrivateMessage,SIM_SETCHILDDIALOG,(LONG)(LPBLDSetChildDialog)&SetChildDialog);
-
- CSimClientDlg* pClient=(CSimClientDlg*)pParentWnd->SendMessage(wPrivateMessage,SIM_GETCHILDDIALOG,0);
- if(pClient)
- {//Need to resize parent if there are client area controls
- CRect rectParent;
- pParentWnd->GetWindowRect(rectParent);
- CSize size = rectParent.Size();
- CRect rectToolbar;
- GetWindowRect(rectToolbar);
- switch(nStyle)
- {
- case CBRS_RIGHT:
- case CBRS_LEFT:
- //Increase the with of the parenwindow
- size.cx +=m_sizeFixedLayout.cx-m_sizeFixedLayoutOld.cx;
- break;
- case CBRS_BOTTOM:
- case CBRS_TOP:
- //Increase the height of the parenwindow
- size.cy +=m_sizeFixedLayout.cy-m_sizeFixedLayoutOld.cy;
- break;
- }
- pParentWnd->SetWindowPos(NULL, 0, 0, size.cx, size.cy,
- SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
- }
- pParentWnd->RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST);
- return retval;
- }
-
-
-
- BOOL CSimToolbar::OnInitDialog()
- {
- return TRUE;
- }
-
-
-
- void CSimToolbar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
- {
- //Overrides the call to this function and set the
- //'bDisableIfNoHndler' to FALSE so Pushbuttons not are disabled
- //See BARDLG.CPP and BARCORE.CPP on the MFC source directory
-
- CDialogBar::OnUpdateCmdUI(pTarget,FALSE);
- }
-
-
-
- LRESULT CSimToolbar::WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
- {
- //In CControlBar (which is the base of CDialogBar) WM_COMMAND,WM_DRAWITEM,
- //WM_MEASUREITEM,WM_DELETEITEM,WM_COMPAREITEM,WM_VKEYTOITEM,
- //WM_CHARTOITEM and WM_VBXEVENT are directly
- //sent to the parent window, see CControlBar::WindowProc in BARCORE.CPP. on
- //the MFC source directory.
- //
- //We want that all messages are handled as in dialog boxes so messages
- //are passed directly to the base of CControlBar, CWnd.
-
- return CWnd::WindowProc(nMsg,wParam,lParam);
- }
-
-
-
- LRESULT CSimToolbar::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- CSize m_sizeFixedLayoutOld; //Old size of toolbar
-
- int Cx,Cy;
- RECT Rect;
-
- if(wParam != SIM_SIZEDIALOG)
- return FALSE;
-
- BLDFindCtrlsRightBottom(this,&Cx,&Cy);
-
- Cx += LOWORD(lParam);
- Cy += HIWORD(lParam);
-
- GetClientRect((LPRECT)&Rect);
- if (Rect.right >= Cx && Rect.bottom >= Cy )
- return TRUE;
-
- m_sizeFixedLayoutOld = m_sizeFixedLayout;
-
- if(Rect.right < Cx)
- {
- switch(ms_nThisStyle)
- {
- case CBRS_RIGHT:
- case CBRS_LEFT:
- m_sizeFixedLayout.cx += Cx - Rect.right;
- break;
- }
- }
-
- if(Rect.bottom < Cy)
- {
- switch(ms_nThisStyle)
- {
- case CBRS_BOTTOM:
- case CBRS_TOP:
- m_sizeFixedLayout.cy += Cy - Rect.bottom;
- break;
- }
- }
- CSimClientDlg* pClient=(CSimClientDlg*)GetParent()->SendMessage(wPrivateMessage,SIM_GETCHILDDIALOG,0);
- if(pClient)
- {//Need to resize parent if there are client area controls
- CRect rectParent;
- GetParent()->GetWindowRect(rectParent);
- CSize size = rectParent.Size();
- CRect rectToolbar;
- GetWindowRect(rectToolbar);
- switch(ms_nThisStyle)
- {
- case CBRS_RIGHT:
- case CBRS_LEFT:
- //Increase the with of the parenwindow
- size.cx +=m_sizeFixedLayout.cx-m_sizeFixedLayoutOld.cx;
- break;
- case CBRS_BOTTOM:
- case CBRS_TOP:
- //Increase the height of the parenwindow
- size.cy +=m_sizeFixedLayout.cy-m_sizeFixedLayoutOld.cy;
- break;
- }
- GetParent()->SetWindowPos(NULL, 0, 0, size.cx, size.cy,
- SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
- }
-
- GetParent()->RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST);
- return TRUE;
- }
-
-
-
- void CSimToolbar::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_VSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimToolbar::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_HSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimToolbar::OnPaint()
- {
- PAINTSTRUCT ps;
- HWND hWnd;
-
- if(!GetUpdateRect((LPRECT)NULL))
- return;
- if(!BeginPaint((LPPAINTSTRUCT)&ps))
- return;
-
- if(ms_szBitmap)
- ::BLDDrawBkgndBitmap(GetSafeHwnd(),(LPPAINTSTRUCT)&ps,ms_szBitmap,0,ms_bStretch,FALSE,ms_xScrolled,ms_yScrolled);
-
- // we use 'HWND's to avoid generation of too many temporary CWnds
- hWnd=::GetWindow(GetSafeHwnd(),GW_CHILD);
-
- while(hWnd)
- {
- ::SendMessage(hWnd,wPrivateMessage,SIM_CTRLPAINT,
- (LONG)(LPPAINTSTRUCT)&ps);
- hWnd=::GetWindow(hWnd,GW_HWNDNEXT);
- }
-
- EndPaint((LPPAINTSTRUCT)&ps);
- }
-
-
-
- HBRUSH CSimToolbar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
-
- if(nCtlColor == CTLCOLOR_DLG)
- {
- if(ms_hBrush)
- {
- int x,y,xScrl,yScrl;
- #ifdef WIN32
- POINT p;
- #else
- CPoint p;
- #endif
-
- if(ms_bScrollSupport)
- {
- yScrl = ms_yScrolled;
- xScrl = ms_xScrolled;
- }
- else
- yScrl=yScrl=0;
- UnrealizeObject(ms_hBrush);
-
- #ifdef WIN32
- ::GetBrushOrgEx(pDC->GetSafeHdc(),&p);
- x=p.x;
- y=p.y;
- #else
- p=pDC->GetBrushOrg();
- x=p.x;
- y=p.y;
- #endif
-
- xScrl=-xScrl+x;
- yScrl=-yScrl+y;
- #ifdef WIN32
- ::SetBrushOrgEx(pDC->GetSafeHdc(),xScrl,yScrl,NULL);
- #else
- pDC->SetBrushOrg(xScrl,yScrl);
- #endif
- ::SelectObject(pDC->GetSafeHdc(),ms_hBrush);//Assertion failed
- //when using pDC->SelectObject
- return ms_hBrush;
- }
- }
- else
- {
- HBRUSH hBrushret;
- #ifdef WIN32
- hBrushret=(HBRUSH)pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,(LPARAM)pDC->m_hDC);
- #else
- hBrushret=(HBRUSH)LOWORD(pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,MAKELONG(pDC->m_hDC,0)));
- #endif
- if(hBrushret)
- return hBrushret;
- }
- if(dwDialogProp&BLDGRAY_DIALOGBOX)
- {
- switch (nCtlColor)
- {
- case CTLCOLOR_LISTBOX:
- case CTLCOLOR_MSGBOX:
- {
- HBRUSH hBrushret;
- hBrushret=BLDGetGlobalBrushDef(pWnd->GetSafeHwnd(),pDC->GetSafeHdc());
- if(hBrushret)
- return hBrushret;
- else
- return CDialogBar::OnCtlColor(pDC,pWnd,nCtlColor);
- }
- break;
- case CTLCOLOR_EDIT:
- if (!(dwDialogProp&BLDGRAY_EDIT))
- return CDialogBar::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_BTN:
- if (!(dwDialogProp&BLDGRAY_BUTTON))
- return CDialogBar::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_SCROLLBAR:
- if (!(dwDialogProp&BLDGRAY_SCROLLBAR))
- return CDialogBar::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_STATIC:
- if (!(dwDialogProp&BLDGRAY_TEXT))
- return CDialogBar::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_DLG:
- break;
- default:
- return CDialogBar::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- }
- pDC->SetBkColor(RGB(192,192,192));
- return (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- }
- return CDialogBar::OnCtlColor(pDC,pWnd,nCtlColor);
- }
-
-
-
- //For default processing of WM_DRAWITEM
- LRESULT CSimToolbar::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
- {
- if(nMsg == WM_DRAWITEM)
- {
- char szStr[20];
- LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
- if(lpDrawItem->CtlType == ODT_BUTTON)
- {
- ::GetWindowText(lpDrawItem->hwndItem,szStr,20);
- if(lstrcmpi( (LPSTR)szStr, (LPSTR)"WMP3DBUTTON") == 0 )
- {
- BLDDrawStateBitmap(lpDrawItem,"","","","",TRUE);
- return TRUE;
- }
- }
- }
- return CDialogBar::DefWindowProc(nMsg,wParam,lParam);
- }
-
-
-
- //To support menues in dialogboxes
- BOOL CSimToolbar::OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo)
- {
- //Control command handling ?
- if (CDialogBar::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- // if not, pump through app
- CWinApp* pApp = AfxGetApp();
- if (pApp != NULL &&
- pApp->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- return FALSE;
- }
-
-
- //This function is from MFC source for class 'CFrameWnd' to
- //support enabling and disabling of menuitems in dialogboxes
- void CSimToolbar::OnInitMenuPopup(CMenu* pMenu, UINT, BOOL bSysMenu)
- {
-
- if (bSysMenu)
- return; // don't support system menu
-
- if(pMenu == NULL)
- return;
-
- // check the enabled state of various menu items
- CCmdUI state;
- state.m_pMenu = pMenu;
-
- state.m_nIndexMax = pMenu->GetMenuItemCount();
- for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
- state.m_nIndex++)
- {
- state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
- if (state.m_nID == 0)
- continue; // menu separator or invalid cmd - ignore it
-
- if (state.m_nID == (UINT)-1)
- {
- // possibly a popup menu, route to first item of that popup
- state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
- if (state.m_pSubMenu == NULL ||
- (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
- state.m_nID == (UINT)-1)
- {
- continue; // first item of popup can't be routed to
- }
- state.DoUpdate(this, FALSE); // popups are never auto disabled
- }
- else
- {
- // normal menu item
- // Auto enable/disable if frame window has 'm_bAutoMenuEnable'
- // set and command is _not_ a system command.
- state.m_pSubMenu = NULL;
- state.DoUpdate(this, ms_bAutoMenuEnable && state.m_nID < 0xF000);
- }
- }
- }
-
-
-
- LRESULT CSimToolbar::OnHelpHitTest(WPARAM wParam, LPARAM lParam)
- {
- if(ms_HelpID)
- return ms_HelpID;
- return CSimToolbar::OnHelpHitTest(wParam, lParam);
- }
-
-
-
- IMPLEMENT_DYNCREATE(CSimToolbar, CDialogBar)
-
- BEGIN_MESSAGE_MAP(CSimToolbar, CDialogBar)
-
- ON_WM_CTLCOLOR()
- ON_WM_PAINT()
- ON_WM_HSCROLL()
- ON_WM_VSCROLL()
- ON_WM_INITMENUPOPUP()
- ON_MESSAGE(WM_HELPHITTEST, OnHelpHitTest)
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
- ON_WM_NCDESTROY()
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member Functions client area controls : CSimClientDlg
- // Base Class : CFormView
- // *************************************************************
-
- CSimClientDlg::CSimClientDlg(LPCSTR lpszTemplateName)
- : CFormView(lpszTemplateName)
- {
- ms_bDeleteBrush=ms_bScrollSupport=FALSE;
- ms_hBrush=0;
- ms_szBitmap=NULL;
- m_bInsideUpdate=TRUE; //This member data is used in MFC
- //CScrollView::UpdateBars to avoid recursiv
- //calls into the function.
- //CScrollView::UpdateBars sets ore removes
- //scrolbars depending in the size of the view.
- //m_bInsideUpdate is set to TRUE here so the
- //function is never executed.
- }
-
-
-
- CSimClientDlg::CSimClientDlg()
- : CFormView((LPCSTR)NULL)
- {
- ms_bDeleteBrush=ms_bScrollSupport=FALSE;
- ms_hBrush=0;
- ms_szBitmap=NULL;
-
- }
-
-
-
- void CSimClientDlg::SimSetTemplate(LPCSTR lpszTemplateName)
- {
- m_lpszTemplateName = lpszTemplateName;
- }
-
-
-
- CSimClientDlg::~CSimClientDlg()
- {
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- if(ms_szBitmap)
- delete ms_szBitmap;
- }
-
-
-
- void CSimClientDlg::OnNcDestroy()
- {
- CWnd* pParentWnd = GetParent();
- BLDSetChildDialog SetChildDialog;
- SetChildDialog.pWnd =NULL;
- SetChildDialog.nStyle=0;
- if(pParentWnd)
- pParentWnd->SendMessage(wPrivateMessage,SIM_SETCHILDDIALOG,(LONG)(LPBLDSetChildDialog)&SetChildDialog);
- CFormView::OnNcDestroy();
- }
-
-
- //Prepares dialog template resource before calling
- //CFormView::Create().
- //This function removes unwanted styles in the template before it calls
- //CFormView::Create which will fail if the style includes WS_VISIBLE
- //and not includes WS_CHILD
-
- BOOL CSimClientDlg::Create(CWnd *pParentWnd)
- {
- //Find parent of type CFrameWnd or derived class.
- if(!pParentWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)))
- {
- pParentWnd = pParentWnd->GetParent();
- while (pParentWnd != NULL)
- {
- if (pParentWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)))
- break;
- pParentWnd = pParentWnd->GetParent();
- }
- }
- if(!pParentWnd)
- {
- return FALSE;
- }
- //Remove old client area controls if any
- CSimClientDlg* pOld=(CSimClientDlg*)pParentWnd->SendMessage(wPrivateMessage,SIM_GETCHILDDIALOG,0);
- if(pOld)
- pOld->DestroyWindow();
-
- HRSRC hResource = ::FindResource(AfxGetResourceHandle(), m_lpszTemplateName, RT_DIALOG);
- if (hResource == NULL)
- {
- return FALSE;
- }
-
- HGLOBAL hTemplate = ::LoadResource(AfxGetResourceHandle(), hResource);
- if (hTemplate == NULL)
- {
- return FALSE;
- }
- // style is first DWORD in resource
- void FAR * lpResource =::LockResource(hTemplate);
-
- DWORD dwOldStyle = *(DWORD FAR*)lpResource;
-
- DWORD tmpdwStyle = dwOldStyle&(CLIENTSTRIP);
- DWORD dwStyle = dwOldStyle^tmpdwStyle;
- dwStyle = dwStyle | WS_CHILD | WS_CLIPSIBLINGS;
-
- *(DWORD FAR*)lpResource= dwStyle; //Set new style dialog template
- CCreateContext CContext;
- //MFC needs a pointer to a CCreateContext
- CContext.m_pNewViewClass =NULL;
- CContext.m_pCurrentDoc =NULL;
- CContext.m_pNewDocTemplate=NULL;
- CContext.m_pLastView =NULL;
- CContext.m_pCurrentFrame =NULL;
- BOOL retval = CFormView::Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
- CRect(0,0,0,0), pParentWnd, AFX_IDW_PANE_FIRST, &CContext);
-
-
- *(DWORD FAR*)lpResource= dwOldStyle; //Reset style
-
- #ifdef WIN32
- // It is not necessary for Win32 applications to unlock resources.
- #else
- ::UnlockResource(hTemplate);
- #endif
-
- ::FreeResource(hTemplate);
-
- if(retval) //There is no OnInitDialog() in base MFC class CFormView
- OnInitDialog(); //so we have to invoke it directly
-
- //Make parent aware of this child window
- BLDSetChildDialog SetChildDialog;
- SetChildDialog.pWnd =this;
- SetChildDialog.nStyle=0;
- pParentWnd->SendMessage(wPrivateMessage,SIM_SETCHILDDIALOG,(LONG)(LPBLDSetChildDialog)&SetChildDialog);
-
- //MFC FormView assumes that scrollbars not are a part of the
- //template so height/width for scrollbars are added if any
- //Remove this extra height/width.
- if(dwOldStyle & WS_HSCROLL)
- m_totalDev.cy-=GetSystemMetrics(SM_CYHSCROLL);
- if(dwOldStyle & WS_VSCROLL)
- m_totalDev.cx-=GetSystemMetrics(SM_CXVSCROLL);
- pParentWnd->RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST);
- ResizeParentToFit(FALSE);
- return retval;
- }
-
-
-
- BOOL CSimClientDlg::OnInitDialog()
- {
- return TRUE;
- }
-
-
-
- LRESULT CSimClientDlg::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- int Cx,Cy;
- RECT Rect;
-
- if(wParam != SIM_SIZEDIALOG)
- return FALSE;
-
- BLDFindCtrlsRightBottom(this,&Cx,&Cy);
-
- Cx += LOWORD(lParam);
- Cy += HIWORD(lParam);
-
- GetClientRect((LPRECT)&Rect);
- if (Rect.right >= Cx && Rect.bottom >= Cy )
- return TRUE;
-
- if(Rect.right < Cx)
- m_totalDev.cx += Cx - Rect.right;
-
- if(Rect.bottom < Cy)
- m_totalDev.cy += Cy - Rect.bottom;
-
- GetParent()->RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST);
- ResizeParentToFit(FALSE);
- return TRUE;
- }
-
-
-
- void CSimClientDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_VSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimClientDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(ms_bScrollSupport)
- {
- ::BLDScrollDlg((CWnd *)this,WM_HSCROLL,nSBCode,nPos,ms_iScrollVertLine,
- ms_iScrollHorLine,ms_iScrollVertPage,ms_iScrollHorPage,ms_iScrollRightOf,
- ms_iScrollBelow,ms_bScrollInvalidate,&ms_xScrolled,&ms_yScrolled);
- }
- }
-
-
-
- void CSimClientDlg::OnPaint()
- {
- PAINTSTRUCT ps;
- HWND hWnd;
-
- if(!GetUpdateRect((LPRECT)NULL))
- return;
- if(!BeginPaint((LPPAINTSTRUCT)&ps))
- return;
-
- if(ms_szBitmap)
- ::BLDDrawBkgndBitmap(GetSafeHwnd(),(LPPAINTSTRUCT)&ps,ms_szBitmap,0,ms_bStretch,FALSE,ms_xScrolled,ms_yScrolled);
-
- // we use 'HWND's to avoid generation of too many temporary CWnds
- hWnd=::GetWindow(GetSafeHwnd(),GW_CHILD);
-
- while(hWnd)
- {
- ::SendMessage(hWnd,wPrivateMessage,SIM_CTRLPAINT,
- (LONG)(LPPAINTSTRUCT)&ps);
- hWnd=::GetWindow(hWnd,GW_HWNDNEXT);
- }
-
- EndPaint((LPPAINTSTRUCT)&ps);
- }
-
-
-
- HBRUSH CSimClientDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
-
- if(nCtlColor == CTLCOLOR_DLG)
- {
- if(ms_hBrush)
- {
- int x,y,xScrl,yScrl;
- #ifdef WIN32
- POINT p;
- #else
- CPoint p;
- #endif
-
- if(ms_bScrollSupport)
- {
- yScrl = ms_yScrolled;
- xScrl = ms_xScrolled;
- }
- else
- yScrl=yScrl=0;
- UnrealizeObject(ms_hBrush);
-
- #ifdef WIN32
- ::GetBrushOrgEx(pDC->GetSafeHdc(),&p);
- x=p.x;
- y=p.y;
- #else
- p=pDC->GetBrushOrg();
- x=p.x;
- y=p.y;
- #endif
-
- xScrl=-xScrl+x;
- yScrl=-yScrl+y;
- #ifdef WIN32
- ::SetBrushOrgEx(pDC->GetSafeHdc(),xScrl,yScrl,NULL);
- #else
- pDC->SetBrushOrg(xScrl,yScrl);
- #endif
- ::SelectObject(pDC->GetSafeHdc(),ms_hBrush);//Assertion failed
- //when using pDC->SelectObject
- return ms_hBrush;
- }
- }
- else
- {
- HBRUSH hBrushret;
- #ifdef WIN32
- hBrushret=(HBRUSH)pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,(LPARAM)pDC->m_hDC);
- #else
- hBrushret=(HBRUSH)LOWORD(pWnd->SendMessage(wPrivateMessage,SIM_CTLCOLOR,MAKELONG(pDC->m_hDC,0)));
- #endif
- if(hBrushret)
- return hBrushret;
- }
- if(dwDialogProp&BLDGRAY_DIALOGBOX)
- {
- switch (nCtlColor)
- {
- case CTLCOLOR_LISTBOX:
- case CTLCOLOR_MSGBOX:
- {
- HBRUSH hBrushret;
- hBrushret=BLDGetGlobalBrushDef(pWnd->GetSafeHwnd(),pDC->GetSafeHdc());
- if(hBrushret)
- return hBrushret;
- else
- return CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
- }
- break;
- case CTLCOLOR_EDIT:
- if (!(dwDialogProp&BLDGRAY_EDIT))
- return CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_BTN:
- if (!(dwDialogProp&BLDGRAY_BUTTON))
- return CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_SCROLLBAR:
- if (!(dwDialogProp&BLDGRAY_SCROLLBAR))
- return CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_STATIC:
- if (!(dwDialogProp&BLDGRAY_TEXT))
- return CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- case CTLCOLOR_DLG:
- break;
- default:
- return CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
- break;
- }
- pDC->SetBkColor(RGB(192,192,192));
- return (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- }
- return CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
- }
-
-
-
- //For default processing of WM_DRAWITEM
- LRESULT CSimClientDlg::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
- {
- if(nMsg == WM_DRAWITEM)
- {
- char szStr[20];
- LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
- if(lpDrawItem->CtlType == ODT_BUTTON)
- {
- ::GetWindowText(lpDrawItem->hwndItem,szStr,20);
- if(lstrcmpi( (LPSTR)szStr, (LPSTR)"WMP3DBUTTON") == 0 )
- {
- BLDDrawStateBitmap(lpDrawItem,"","","","",TRUE);
- return TRUE;
- }
- }
- }
- return CFormView::DefWindowProc(nMsg,wParam,lParam);
- }
-
-
-
- //To support menues in dialogboxes
- BOOL CSimClientDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo)
- {
- //Control command handling ?
- if (CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- // if not, pump through app
- CWinApp* pApp = AfxGetApp();
- if (pApp != NULL &&
- pApp->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
-
- return FALSE;
- }
-
-
- //This function is from MFC source for class 'CFrameWnd' to
- //support enabling and disabling of menuitems in dialogboxes
- void CSimClientDlg::OnInitMenuPopup(CMenu* pMenu, UINT, BOOL bSysMenu)
- {
-
- if (bSysMenu)
- return; // don't support system menu
-
- if(pMenu == NULL)
- return;
-
- // check the enabled state of various menu items
- CCmdUI state;
- state.m_pMenu = pMenu;
-
- state.m_nIndexMax = pMenu->GetMenuItemCount();
- for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
- state.m_nIndex++)
- {
- state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
- if (state.m_nID == 0)
- continue; // menu separator or invalid cmd - ignore it
-
- if (state.m_nID == (UINT)-1)
- {
- // possibly a popup menu, route to first item of that popup
- state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
- if (state.m_pSubMenu == NULL ||
- (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
- state.m_nID == (UINT)-1)
- {
- continue; // first item of popup can't be routed to
- }
- state.DoUpdate(this, FALSE); // popups are never auto disabled
- }
- else
- {
- // normal menu item
- // Auto enable/disable if frame window has 'm_bAutoMenuEnable'
- // set and command is _not_ a system command.
- state.m_pSubMenu = NULL;
- state.DoUpdate(this, ms_bAutoMenuEnable && state.m_nID < 0xF000);
- }
- }
- }
-
-
-
- LRESULT CSimClientDlg::OnHelpHitTest(WPARAM wParam, LPARAM lParam)
- {
- if(ms_HelpID)
- return ms_HelpID;
- return CSimClientDlg::OnHelpHitTest(wParam, lParam);
- }
-
-
-
- IMPLEMENT_DYNCREATE(CSimClientDlg, CFormView)
-
- BEGIN_MESSAGE_MAP(CSimClientDlg, CFormView)
-
- ON_WM_CTLCOLOR()
- ON_WM_PAINT()
- ON_WM_HSCROLL()
- ON_WM_VSCROLL()
- ON_WM_INITMENUPOPUP()
- ON_MESSAGE(WM_HELPHITTEST, OnHelpHitTest)
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
- ON_WM_NCDESTROY()
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimScrollBar
- // Base Class : CScrollBar
- // *************************************************************
-
- CSimScrollBar::CSimScrollBar()
- : CScrollBar()
- {
- ms_bTextColor=ms_bBkColor=ms_bBkMode=ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- };
-
-
-
- CSimScrollBar::~CSimScrollBar()
- {
- if(ms_hFont)
- DeleteObject(ms_hFont);
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- }
-
-
-
- BOOL CSimScrollBar::SimInitCtrlFont(int nHeight,int nWidth,int nEscapement,
- int nOrientation,int fnWeight,BYTE fbItalic,BYTE fbUnderline,
- BYTE fbStrikeOut,BYTE fbCharSet,BYTE fbOutputPrecision,
- BYTE fbClipPrecision,BYTE fbQuality,BYTE fbPitchAndFamily,
- char *lpszFace)
- {
- ms_hFont=CreateFont(nHeight, nWidth, nEscapement,
- nOrientation,fnWeight, fbItalic, fbUnderline,
- fbStrikeOut, fbCharSet,fbOutputPrecision,
- fbClipPrecision, fbQuality,
- fbPitchAndFamily, lpszFace);
- if(ms_hFont&&GetSafeHwnd())
- {
- SendMessage(WM_SETFONT,(WPARAM)ms_hFont,(LPARAM)TRUE);
- return TRUE;
- }
- return FALSE;
- }
-
-
-
- BOOL CSimScrollBar::SimInitSolidBrush(COLORREF ColorRef)
- {
- ms_hBrush=CreateSolidBrush(ColorRef);
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimScrollBar::SimInitPatternBrush(char *pBitmapName)
- {
- HBITMAP hBitmap;
-
- hBitmap = BLDLoadBitmap(AfxGetResourceHandle(),pBitmapName);
- if(hBitmap)
- {
- ms_hBrush = CreatePatternBrush(hBitmap);
- DeleteObject(hBitmap);
- }
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimScrollBar::SimInitStockBrush(int fnObject)
- {
- ms_hBrush=(HBRUSH)GetStockObject(fnObject);
- ms_bDeleteBrush = FALSE;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimScrollBar::SimInitTextColor(BOOL bInTextColor,COLORREF InTextColorRef,BOOL bInBkColor,COLORREF InBkColorRef,int fnInBkMode)
- {
- ms_bTextColor = bInTextColor;
- ms_TextColorRef = InTextColorRef;
- ms_bBkColor = bInBkColor;
- ms_BkColorRef = InBkColorRef;
- ms_fnBkMode = fnInBkMode;
- ms_bBkMode = TRUE;
- return TRUE;
- }
-
-
-
- LRESULT CSimScrollBar::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- HBRUSH hBrushRet;
- HDC hDC;
-
- #ifdef WIN32
- hDC = (HDC)lParam;
- #else
- hDC = (HDC)LOWORD(lParam);
- #endif
-
- if(wParam != SIM_CTLCOLOR)
- return FALSE;
- if(!ms_hBrush && !ms_bTextColor && !ms_bBkColor && !ms_bBkMode)
- return NULL; //No CtlColor Functionality
- if(ms_hBrush)
- hBrushRet = ms_hBrush;
- else
- hBrushRet = ::BLDGetGlobalBrushDef(m_hWnd,hDC);
-
- if(!hBrushRet)
- #ifdef WIN32
- hBrushRet=(HBRUSH)::GetClassLong(m_hWnd,GCL_HBRBACKGROUND);
- #else
- hBrushRet=(HBRUSH)::GetClassWord(m_hWnd,GCW_HBRBACKGROUND);
- #endif
- if(!hBrushRet)
- hBrushRet = (HBRUSH)::GetStockObject(WHITE_BRUSH);
-
- if(ms_bTextColor)
- ::SetTextColor(hDC,ms_TextColorRef);
-
- if(ms_bBkColor)
- ::SetBkColor(hDC,ms_BkColorRef);
-
- if(ms_bBkMode)
- ::SetBkMode(hDC,ms_fnBkMode);
-
- #ifdef WIN32
- return (LRESULT)hBrushRet;
- #else
- return MAKELONG(hBrushRet,0);
- #endif
- }
-
-
- IMPLEMENT_DYNCREATE(CSimScrollBar, CScrollBar)
-
- BEGIN_MESSAGE_MAP(CSimScrollBar, CScrollBar)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimStatic
- // Base Class : CStatic
- // *************************************************************
-
- CSimStatic::CSimStatic()
- : CStatic()
- {
- ms_bTextColor=ms_bBkColor=ms_bBkMode=ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- };
-
-
-
- CSimStatic::~CSimStatic()
- {
- if(ms_hFont)
- DeleteObject(ms_hFont);
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- }
-
-
-
- BOOL CSimStatic::SimInitCtrlFont(int nHeight,int nWidth,int nEscapement,
- int nOrientation,int fnWeight,BYTE fbItalic,BYTE fbUnderline,
- BYTE fbStrikeOut,BYTE fbCharSet,BYTE fbOutputPrecision,
- BYTE fbClipPrecision,BYTE fbQuality,BYTE fbPitchAndFamily,
- char *lpszFace)
- {
- ms_hFont=CreateFont(nHeight, nWidth, nEscapement,
- nOrientation,fnWeight, fbItalic, fbUnderline,
- fbStrikeOut, fbCharSet,fbOutputPrecision,
- fbClipPrecision, fbQuality,
- fbPitchAndFamily, lpszFace);
- if(ms_hFont&&GetSafeHwnd())
- {
- SendMessage(WM_SETFONT,(WPARAM)ms_hFont,(LPARAM)TRUE);
- return TRUE;
- }
- return FALSE;
- }
-
-
-
- BOOL CSimStatic::SimInitSolidBrush(COLORREF ColorRef)
- {
- ms_hBrush=CreateSolidBrush(ColorRef);
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimStatic::SimInitPatternBrush(char *pBitmapName)
- {
- HBITMAP hBitmap;
-
- hBitmap = BLDLoadBitmap(AfxGetResourceHandle(),pBitmapName);
- if(hBitmap)
- {
- ms_hBrush = CreatePatternBrush(hBitmap);
- DeleteObject(hBitmap);
- }
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimStatic::SimInitStockBrush(int fnObject)
- {
- ms_hBrush=(HBRUSH)GetStockObject(fnObject);
- ms_bDeleteBrush = FALSE;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimStatic::SimInitTextColor(BOOL bInTextColor,COLORREF InTextColorRef,BOOL bInBkColor,COLORREF InBkColorRef,int fnInBkMode)
- {
- ms_bTextColor = bInTextColor;
- ms_TextColorRef = InTextColorRef;
- ms_bBkColor = bInBkColor;
- ms_BkColorRef = InBkColorRef;
- ms_fnBkMode = fnInBkMode;
- ms_bBkMode = TRUE;
- return TRUE;
- }
-
-
-
- LRESULT CSimStatic::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- HBRUSH hBrushRet;
- HDC hDC;
-
- #ifdef WIN32
- hDC = (HDC)lParam;
- #else
- hDC = (HDC)LOWORD(lParam);
- #endif
-
- if(wParam != SIM_CTLCOLOR)
- return FALSE;
- if(!ms_hBrush && !ms_bTextColor && !ms_bBkColor && !ms_bBkMode)
- return NULL; //No CtlColor Functionality
- if(ms_hBrush)
- hBrushRet = ms_hBrush;
- else
- hBrushRet = ::BLDGetGlobalBrushDef(m_hWnd,hDC);
-
- if(!hBrushRet)
- #ifdef WIN32
- hBrushRet=(HBRUSH)::GetClassLong(m_hWnd,GCL_HBRBACKGROUND);
- #else
- hBrushRet=(HBRUSH)::GetClassWord(m_hWnd,GCW_HBRBACKGROUND);
- #endif
- if(!hBrushRet)
- hBrushRet = (HBRUSH)::GetStockObject(WHITE_BRUSH);
-
- if(ms_bTextColor)
- ::SetTextColor(hDC,ms_TextColorRef);
-
- if(ms_bBkColor)
- ::SetBkColor(hDC,ms_BkColorRef);
-
- if(ms_bBkMode)
- ::SetBkMode(hDC,ms_fnBkMode);
-
- #ifdef WIN32
- return (LRESULT)hBrushRet;
- #else
- return MAKELONG(hBrushRet,0);
- #endif
- }
-
-
- IMPLEMENT_DYNCREATE(CSimStatic, CStatic)
-
- BEGIN_MESSAGE_MAP(CSimStatic, CStatic)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimEdit
- // Base Class : CEdit
- // *************************************************************
-
- CSimEdit::CSimEdit()
- : CEdit()
- {
- ms_bTextColor=ms_bBkColor=ms_bBkMode=ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- };
-
-
-
- CSimEdit::~CSimEdit()
- {
- if(ms_hFont)
- DeleteObject(ms_hFont);
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- }
-
-
-
- BOOL CSimEdit::SimInitCtrlFont(int nHeight,int nWidth,int nEscapement,
- int nOrientation,int fnWeight,BYTE fbItalic,BYTE fbUnderline,
- BYTE fbStrikeOut,BYTE fbCharSet,BYTE fbOutputPrecision,
- BYTE fbClipPrecision,BYTE fbQuality,BYTE fbPitchAndFamily,
- char *lpszFace)
- {
- ms_hFont=CreateFont(nHeight, nWidth, nEscapement,
- nOrientation,fnWeight, fbItalic, fbUnderline,
- fbStrikeOut, fbCharSet,fbOutputPrecision,
- fbClipPrecision, fbQuality,
- fbPitchAndFamily, lpszFace);
- if(ms_hFont&&GetSafeHwnd())
- {
- SendMessage(WM_SETFONT,(WPARAM)ms_hFont,(LPARAM)TRUE);
- return TRUE;
- }
- return FALSE;
- }
-
-
-
- BOOL CSimEdit::SimInitSolidBrush(COLORREF ColorRef)
- {
- ms_hBrush=CreateSolidBrush(ColorRef);
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimEdit::SimInitPatternBrush(char *pBitmapName)
- {
- HBITMAP hBitmap;
-
- hBitmap = BLDLoadBitmap(AfxGetResourceHandle(),pBitmapName);
- if(hBitmap)
- {
- ms_hBrush = CreatePatternBrush(hBitmap);
- DeleteObject(hBitmap);
- }
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimEdit::SimInitStockBrush(int fnObject)
- {
- ms_hBrush=(HBRUSH)GetStockObject(fnObject);
- ms_bDeleteBrush = FALSE;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimEdit::SimInitTextColor(BOOL bInTextColor,COLORREF InTextColorRef,BOOL bInBkColor,COLORREF InBkColorRef,int fnInBkMode)
- {
- ms_bTextColor = bInTextColor;
- ms_TextColorRef = InTextColorRef;
- ms_bBkColor = bInBkColor;
- ms_BkColorRef = InBkColorRef;
- ms_fnBkMode = fnInBkMode;
- ms_bBkMode = TRUE;
- return TRUE;
- }
-
-
-
- LRESULT CSimEdit::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- HBRUSH hBrushRet;
- HDC hDC;
-
- #ifdef WIN32
- hDC = (HDC)lParam;
- #else
- hDC = (HDC)LOWORD(lParam);
- #endif
-
- if(wParam != SIM_CTLCOLOR)
- return FALSE;
- if(!ms_hBrush && !ms_bTextColor && !ms_bBkColor && !ms_bBkMode)
- return NULL; //No CtlColor Functionality
- if(ms_hBrush)
- hBrushRet = ms_hBrush;
- else
- hBrushRet = ::BLDGetGlobalBrushDef(m_hWnd,hDC);
-
- if(!hBrushRet)
- #ifdef WIN32
- hBrushRet=(HBRUSH)::GetClassLong(m_hWnd,GCL_HBRBACKGROUND);
- #else
- hBrushRet=(HBRUSH)::GetClassWord(m_hWnd,GCW_HBRBACKGROUND);
- #endif
- if(!hBrushRet)
- hBrushRet = (HBRUSH)::GetStockObject(WHITE_BRUSH);
-
- if(ms_bTextColor)
- ::SetTextColor(hDC,ms_TextColorRef);
-
- if(ms_bBkColor)
- ::SetBkColor(hDC,ms_BkColorRef);
-
- if(ms_bBkMode)
- ::SetBkMode(hDC,ms_fnBkMode);
-
- #ifdef WIN32
- return (LRESULT)hBrushRet;
- #else
- return MAKELONG(hBrushRet,0);
- #endif
- }
-
-
- IMPLEMENT_DYNCREATE(CSimEdit, CEdit)
-
- BEGIN_MESSAGE_MAP(CSimEdit, CEdit)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimListBox
- // Base Class : CListBox
- // *************************************************************
-
- CSimListBox::CSimListBox()
- : CListBox()
- {
- ms_bTextColor=ms_bBkColor=ms_bBkMode=ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- };
-
-
-
- CSimListBox::~CSimListBox()
- {
- if(ms_hFont)
- DeleteObject(ms_hFont);
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- }
-
-
-
- BOOL CSimListBox::SimInitCtrlFont(int nHeight,int nWidth,int nEscapement,
- int nOrientation,int fnWeight,BYTE fbItalic,BYTE fbUnderline,
- BYTE fbStrikeOut,BYTE fbCharSet,BYTE fbOutputPrecision,
- BYTE fbClipPrecision,BYTE fbQuality,BYTE fbPitchAndFamily,
- char *lpszFace)
- {
- ms_hFont=CreateFont(nHeight, nWidth, nEscapement,
- nOrientation,fnWeight, fbItalic, fbUnderline,
- fbStrikeOut, fbCharSet,fbOutputPrecision,
- fbClipPrecision, fbQuality,
- fbPitchAndFamily, lpszFace);
- if(ms_hFont&&GetSafeHwnd())
- {
- SendMessage(WM_SETFONT,(WPARAM)ms_hFont,(LPARAM)TRUE);
- return TRUE;
- }
- return FALSE;
- }
-
-
-
- BOOL CSimListBox::SimInitSolidBrush(COLORREF ColorRef)
- {
- ms_hBrush=CreateSolidBrush(ColorRef);
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimListBox::SimInitPatternBrush(char *pBitmapName)
- {
- HBITMAP hBitmap;
-
- hBitmap = BLDLoadBitmap(AfxGetResourceHandle(),pBitmapName);
- if(hBitmap)
- {
- ms_hBrush = CreatePatternBrush(hBitmap);
- DeleteObject(hBitmap);
- }
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimListBox::SimInitStockBrush(int fnObject)
- {
- ms_hBrush=(HBRUSH)GetStockObject(fnObject);
- ms_bDeleteBrush = FALSE;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimListBox::SimInitTextColor(BOOL bInTextColor,COLORREF InTextColorRef,BOOL bInBkColor,COLORREF InBkColorRef,int fnInBkMode)
- {
- ms_bTextColor = bInTextColor;
- ms_TextColorRef = InTextColorRef;
- ms_bBkColor = bInBkColor;
- ms_BkColorRef = InBkColorRef;
- ms_fnBkMode = fnInBkMode;
- ms_bBkMode = TRUE;
- return TRUE;
- }
-
-
-
- LRESULT CSimListBox::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- HBRUSH hBrushRet;
- HDC hDC;
-
- #ifdef WIN32
- hDC = (HDC)lParam;
- #else
- hDC = (HDC)LOWORD(lParam);
- #endif
-
- if(wParam != SIM_CTLCOLOR)
- return FALSE;
- if(!ms_hBrush && !ms_bTextColor && !ms_bBkColor && !ms_bBkMode)
- return NULL; //No CtlColor Functionality
- if(ms_hBrush)
- hBrushRet = ms_hBrush;
- else
- hBrushRet = ::BLDGetGlobalBrushDef(m_hWnd,hDC);
-
- if(!hBrushRet)
- #ifdef WIN32
- hBrushRet=(HBRUSH)::GetClassLong(m_hWnd,GCL_HBRBACKGROUND);
- #else
- hBrushRet=(HBRUSH)::GetClassWord(m_hWnd,GCW_HBRBACKGROUND);
- #endif
- if(!hBrushRet)
- hBrushRet = (HBRUSH)::GetStockObject(WHITE_BRUSH);
-
- if(ms_bTextColor)
- ::SetTextColor(hDC,ms_TextColorRef);
-
- if(ms_bBkColor)
- ::SetBkColor(hDC,ms_BkColorRef);
-
- if(ms_bBkMode)
- ::SetBkMode(hDC,ms_fnBkMode);
-
- #ifdef WIN32
- return (LRESULT)hBrushRet;
- #else
- return MAKELONG(hBrushRet,0);
- #endif
- }
-
-
- IMPLEMENT_DYNCREATE(CSimListBox, CListBox)
-
- BEGIN_MESSAGE_MAP(CSimListBox, CListBox)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimComboBox
- // Base Class : CComboBox
- // *************************************************************
-
- CSimComboBox::CSimComboBox()
- : CComboBox()
- {
- ms_bTextColor=ms_bBkColor=ms_bBkMode=ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- };
-
-
-
- CSimComboBox::~CSimComboBox()
- {
- if(ms_hFont)
- DeleteObject(ms_hFont);
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- }
-
-
-
- BOOL CSimComboBox::SimInitCtrlFont(int nHeight,int nWidth,int nEscapement,
- int nOrientation,int fnWeight,BYTE fbItalic,BYTE fbUnderline,
- BYTE fbStrikeOut,BYTE fbCharSet,BYTE fbOutputPrecision,
- BYTE fbClipPrecision,BYTE fbQuality,BYTE fbPitchAndFamily,
- char *lpszFace)
- {
- ms_hFont=CreateFont(nHeight, nWidth, nEscapement,
- nOrientation,fnWeight, fbItalic, fbUnderline,
- fbStrikeOut, fbCharSet,fbOutputPrecision,
- fbClipPrecision, fbQuality,
- fbPitchAndFamily, lpszFace);
- if(ms_hFont&&GetSafeHwnd())
- {
- SendMessage(WM_SETFONT,(WPARAM)ms_hFont,(LPARAM)TRUE);
- return TRUE;
- }
- return FALSE;
- }
-
-
-
- BOOL CSimComboBox::SimInitSolidBrush(COLORREF ColorRef)
- {
- ms_hBrush=CreateSolidBrush(ColorRef);
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimComboBox::SimInitPatternBrush(char *pBitmapName)
- {
- HBITMAP hBitmap;
-
- hBitmap = BLDLoadBitmap(AfxGetResourceHandle(),pBitmapName);
- if(hBitmap)
- {
- ms_hBrush = CreatePatternBrush(hBitmap);
- DeleteObject(hBitmap);
- }
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimComboBox::SimInitStockBrush(int fnObject)
- {
- ms_hBrush=(HBRUSH)GetStockObject(fnObject);
- ms_bDeleteBrush = FALSE;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimComboBox::SimInitTextColor(BOOL bInTextColor,COLORREF InTextColorRef,BOOL bInBkColor,COLORREF InBkColorRef,int fnInBkMode)
- {
- ms_bTextColor = bInTextColor;
- ms_TextColorRef = InTextColorRef;
- ms_bBkColor = bInBkColor;
- ms_BkColorRef = InBkColorRef;
- ms_fnBkMode = fnInBkMode;
- ms_bBkMode = TRUE;
- return TRUE;
- }
-
-
-
- LRESULT CSimComboBox::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- HBRUSH hBrushRet;
- HDC hDC;
-
- #ifdef WIN32
- hDC = (HDC)lParam;
- #else
- hDC = (HDC)LOWORD(lParam);
- #endif
-
- if(wParam != SIM_CTLCOLOR)
- return FALSE;
- if(!ms_hBrush && !ms_bTextColor && !ms_bBkColor && !ms_bBkMode)
- return NULL; //No CtlColor Functionality
- if(ms_hBrush)
- hBrushRet = ms_hBrush;
- else
- hBrushRet = ::BLDGetGlobalBrushDef(m_hWnd,hDC);
-
- if(!hBrushRet)
- #ifdef WIN32
- hBrushRet=(HBRUSH)::GetClassLong(m_hWnd,GCL_HBRBACKGROUND);
- #else
- hBrushRet=(HBRUSH)::GetClassWord(m_hWnd,GCW_HBRBACKGROUND);
- #endif
- if(!hBrushRet)
- hBrushRet = (HBRUSH)::GetStockObject(WHITE_BRUSH);
-
- if(ms_bTextColor)
- ::SetTextColor(hDC,ms_TextColorRef);
-
- if(ms_bBkColor)
- ::SetBkColor(hDC,ms_BkColorRef);
-
- if(ms_bBkMode)
- ::SetBkMode(hDC,ms_fnBkMode);
-
- #ifdef WIN32
- return (LRESULT)hBrushRet;
- #else
- return MAKELONG(hBrushRet,0);
- #endif
- }
-
-
- IMPLEMENT_DYNCREATE(CSimComboBox, CComboBox)
-
- BEGIN_MESSAGE_MAP(CSimComboBox, CComboBox)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimButton
- // Base Class : CButton
- // *************************************************************
-
- CSimButton::CSimButton()
- : CButton()
- {
- ms_bTextColor=ms_bBkColor=ms_bBkMode=ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- };
-
-
-
- CSimButton::~CSimButton()
- {
- if(ms_hFont)
- DeleteObject(ms_hFont);
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- }
-
-
-
- BOOL CSimButton::SimInitCtrlFont(int nHeight,int nWidth,int nEscapement,
- int nOrientation,int fnWeight,BYTE fbItalic,BYTE fbUnderline,
- BYTE fbStrikeOut,BYTE fbCharSet,BYTE fbOutputPrecision,
- BYTE fbClipPrecision,BYTE fbQuality,BYTE fbPitchAndFamily,
- char *lpszFace)
- {
- ms_hFont=CreateFont(nHeight, nWidth, nEscapement,
- nOrientation,fnWeight, fbItalic, fbUnderline,
- fbStrikeOut, fbCharSet,fbOutputPrecision,
- fbClipPrecision, fbQuality,
- fbPitchAndFamily, lpszFace);
- if(ms_hFont&&GetSafeHwnd())
- {
- SendMessage(WM_SETFONT,(WPARAM)ms_hFont,(LPARAM)TRUE);
- return TRUE;
- }
- return FALSE;
- }
-
-
-
- BOOL CSimButton::SimInitSolidBrush(COLORREF ColorRef)
- {
- ms_hBrush=CreateSolidBrush(ColorRef);
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimButton::SimInitPatternBrush(char *pBitmapName)
- {
- HBITMAP hBitmap;
-
- hBitmap = BLDLoadBitmap(AfxGetResourceHandle(),pBitmapName);
- if(hBitmap)
- {
- ms_hBrush = CreatePatternBrush(hBitmap);
- DeleteObject(hBitmap);
- }
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimButton::SimInitStockBrush(int fnObject)
- {
- ms_hBrush=(HBRUSH)GetStockObject(fnObject);
- ms_bDeleteBrush = FALSE;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimButton::SimInitTextColor(BOOL bInTextColor,COLORREF InTextColorRef,BOOL bInBkColor,COLORREF InBkColorRef,int fnInBkMode)
- {
- ms_bTextColor = bInTextColor;
- ms_TextColorRef = InTextColorRef;
- ms_bBkColor = bInBkColor;
- ms_BkColorRef = InBkColorRef;
- ms_fnBkMode = fnInBkMode;
- ms_bBkMode = TRUE;
- return TRUE;
- }
-
-
-
- LRESULT CSimButton::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- HBRUSH hBrushRet;
- HDC hDC;
-
- #ifdef WIN32
- hDC = (HDC)lParam;
- #else
- hDC = (HDC)LOWORD(lParam);
- #endif
-
- if(wParam != SIM_CTLCOLOR)
- return FALSE;
- if(!ms_hBrush && !ms_bTextColor && !ms_bBkColor && !ms_bBkMode)
- return NULL; //No CtlColor Functionality
- if(ms_hBrush)
- hBrushRet = ms_hBrush;
- else
- hBrushRet = ::BLDGetGlobalBrushDef(m_hWnd,hDC);
-
- if(!hBrushRet)
- #ifdef WIN32
- hBrushRet=(HBRUSH)::GetClassLong(m_hWnd,GCL_HBRBACKGROUND);
- #else
- hBrushRet=(HBRUSH)::GetClassWord(m_hWnd,GCW_HBRBACKGROUND);
- #endif
- if(!hBrushRet)
- hBrushRet = (HBRUSH)::GetStockObject(WHITE_BRUSH);
-
- if(ms_bTextColor)
- ::SetTextColor(hDC,ms_TextColorRef);
-
- if(ms_bBkColor)
- ::SetBkColor(hDC,ms_BkColorRef);
-
- if(ms_bBkMode)
- ::SetBkMode(hDC,ms_fnBkMode);
-
- #ifdef WIN32
- return (LRESULT)hBrushRet;
- #else
- return MAKELONG(hBrushRet,0);
- #endif
- }
-
-
- IMPLEMENT_DYNCREATE(CSimButton, CButton)
-
- BEGIN_MESSAGE_MAP(CSimButton, CButton)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimCustom
- // Base Class : CWnd
- // *************************************************************
-
- CSimCustom::CSimCustom()
- : CWnd()
- {
- ms_bTextColor=ms_bBkColor=ms_bBkMode=ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- };
-
-
-
- CSimCustom::~CSimCustom()
- {
- if(ms_hFont)
- DeleteObject(ms_hFont);
- if(ms_bDeleteBrush && ms_hBrush)
- DeleteObject(ms_hBrush);
- ms_bDeleteBrush=FALSE;
- ms_hBrush=0;
- ms_hFont=0;
- }
-
-
-
- BOOL CSimCustom::SimInitCtrlFont(int nHeight,int nWidth,int nEscapement,
- int nOrientation,int fnWeight,BYTE fbItalic,BYTE fbUnderline,
- BYTE fbStrikeOut,BYTE fbCharSet,BYTE fbOutputPrecision,
- BYTE fbClipPrecision,BYTE fbQuality,BYTE fbPitchAndFamily,
- char *lpszFace)
- {
- ms_hFont=CreateFont(nHeight, nWidth, nEscapement,
- nOrientation,fnWeight, fbItalic, fbUnderline,
- fbStrikeOut, fbCharSet,fbOutputPrecision,
- fbClipPrecision, fbQuality,
- fbPitchAndFamily, lpszFace);
- if(ms_hFont&&GetSafeHwnd())
- {
- SendMessage(WM_SETFONT,(WPARAM)ms_hFont,(LPARAM)TRUE);
- return TRUE;
- }
- return FALSE;
- }
-
-
-
- BOOL CSimCustom::SimInitSolidBrush(COLORREF ColorRef)
- {
- ms_hBrush=CreateSolidBrush(ColorRef);
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimCustom::SimInitPatternBrush(char *pBitmapName)
- {
- HBITMAP hBitmap;
-
- hBitmap = BLDLoadBitmap(AfxGetResourceHandle(),pBitmapName);
- if(hBitmap)
- {
- ms_hBrush = CreatePatternBrush(hBitmap);
- DeleteObject(hBitmap);
- }
- ms_bDeleteBrush = (BOOL) ms_hBrush;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimCustom::SimInitStockBrush(int fnObject)
- {
- ms_hBrush=(HBRUSH)GetStockObject(fnObject);
- ms_bDeleteBrush = FALSE;
- return (BOOL) ms_hBrush;
- }
-
-
-
- BOOL CSimCustom::SimInitTextColor(BOOL bInTextColor,COLORREF InTextColorRef,BOOL bInBkColor,COLORREF InBkColorRef,int fnInBkMode)
- {
- ms_bTextColor = bInTextColor;
- ms_TextColorRef = InTextColorRef;
- ms_bBkColor = bInBkColor;
- ms_BkColorRef = InBkColorRef;
- ms_fnBkMode = fnInBkMode;
- ms_bBkMode = TRUE;
- return TRUE;
- }
-
-
-
- LRESULT CSimCustom::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- HBRUSH hBrushRet;
- HDC hDC;
-
- #ifdef WIN32
- hDC = (HDC)lParam;
- #else
- hDC = (HDC)LOWORD(lParam);
- #endif
-
- if(wParam != SIM_CTLCOLOR)
- return FALSE;
- if(!ms_hBrush && !ms_bTextColor && !ms_bBkColor && !ms_bBkMode)
- return NULL; //No CtlColor Functionality
- if(ms_hBrush)
- hBrushRet = ms_hBrush;
- else
- hBrushRet = ::BLDGetGlobalBrushDef(m_hWnd,hDC);
-
- if(!hBrushRet)
- #ifdef WIN32
- hBrushRet=(HBRUSH)::GetClassLong(m_hWnd,GCL_HBRBACKGROUND);
- #else
- hBrushRet=(HBRUSH)::GetClassWord(m_hWnd,GCW_HBRBACKGROUND);
- #endif
- if(!hBrushRet)
- hBrushRet = (HBRUSH)::GetStockObject(WHITE_BRUSH);
-
- if(ms_bTextColor)
- ::SetTextColor(hDC,ms_TextColorRef);
-
- if(ms_bBkColor)
- ::SetBkColor(hDC,ms_BkColorRef);
-
- if(ms_bBkMode)
- ::SetBkMode(hDC,ms_fnBkMode);
-
- #ifdef WIN32
- return (LRESULT)hBrushRet;
- #else
- return MAKELONG(hBrushRet,0);
- #endif
- }
-
-
- IMPLEMENT_DYNCREATE(CSimCustom, CWnd)
-
- BEGIN_MESSAGE_MAP(CSimCustom, CWnd)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- // *************************************************************
- // Member function for Class : CSimGraphicButton
- // Base Class : CButton
- // *************************************************************
-
- CSimGraphicButton::CSimGraphicButton()
- : CButton()
- {
- ms_szBitmap = NULL;
- ms_szNormal = NULL;
- ms_szFocus = NULL;
- ms_szSelected= NULL;
- ms_szDisabled= NULL;
- ms_bHidden = FALSE;
- }
-
-
- CSimGraphicButton::~CSimGraphicButton()
- {
- ClearData();
- }
-
-
-
- void CSimGraphicButton::ClearData()
- {
- if(ms_szBitmap)
- delete ms_szBitmap;
- if(ms_szNormal)
- delete ms_szNormal;
- if(ms_szFocus)
- delete ms_szFocus;
- if(ms_szSelected)
- delete ms_szSelected;
- if(ms_szDisabled)
- delete ms_szDisabled;
- ms_szBitmap = NULL;
- ms_szNormal = NULL;
- ms_szFocus = NULL;
- ms_szSelected= NULL;
- ms_szDisabled= NULL;
- }
-
-
-
- void CSimGraphicButton::SimSetGraphicData(char * szBitmap,BOOL bBitmap,BOOL bStretch)
- {
- ClearData();
- ms_iGraphicType = SIM_GRAPHIC;
- ms_szBitmap = new char[lstrlen(szBitmap)+1];
- if(ms_szBitmap)
- lstrcpy(ms_szBitmap,szBitmap);
- ms_bBitmap = bBitmap;
- ms_bStretch = bStretch;
- }
-
-
-
- void CSimGraphicButton::SimSetGraphicDataBkGrnd(char * szBitmap,BOOL bBitmap,BOOL bStretch)
- {
- ClearData();
- ms_iGraphicType = SIM_GRAPHIC_BKGRND;
- ms_szBitmap = new char[lstrlen(szBitmap)+1];
- if(ms_szBitmap)
- lstrcpy(ms_szBitmap,szBitmap);
- ms_bBitmap = bBitmap;
- ms_bStretch = bStretch;
- }
-
-
- void CSimGraphicButton::SimSetGraphicData3D(char *szNormal,char *szFocus,char *szSelected,
- char *szDisabled,BOOL bBitmap,BOOL bStretch)
- {
- ClearData();
- ms_iGraphicType = SIM_GRAPHIC_3D;
- ms_szNormal = new char[lstrlen(szNormal)+1];
- if(ms_szNormal)
- lstrcpy(ms_szNormal,szNormal);
- ms_szFocus = new char[lstrlen(szFocus)+1];
- if(ms_szFocus)
- lstrcpy(ms_szFocus,szFocus);
- ms_szSelected = new char[lstrlen(szSelected)+1];
- if(ms_szSelected)
- lstrcpy(ms_szSelected,szSelected);
- ms_szDisabled = new char[lstrlen(szDisabled)+1];
- if(ms_szDisabled)
- lstrcpy(ms_szDisabled,szDisabled);
- ms_bBitmap = bBitmap;
- ms_bStretch = bStretch;
- }
-
-
-
- void CSimGraphicButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
- switch(ms_iGraphicType)
- {
- case SIM_GRAPHIC:
- if (lpDrawItemStruct->itemAction!=ODA_DRAWENTIRE)
- return;
- if(ms_bBitmap)
- BLDDrawBitmap(lpDrawItemStruct,ms_szBitmap,ms_bStretch);
- else
- BLDDrawIcon(lpDrawItemStruct,ms_szBitmap);
- break;
- case SIM_GRAPHIC_3D:
- if(ms_bBitmap)
- BLDDrawStateBitmap(lpDrawItemStruct,ms_szNormal,ms_szFocus,ms_szSelected,ms_szDisabled,ms_bStretch);
- else
- BLDDrawStateIcon(lpDrawItemStruct,ms_szNormal,ms_szFocus,ms_szSelected,ms_szDisabled);
- break;
- }
- }
-
-
-
- LRESULT CSimGraphicButton::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- LPPAINTSTRUCT lpps;
-
- if(ms_iGraphicType != SIM_GRAPHIC_BKGRND)
- return FALSE;
- if(wParam != SIM_CTRLPAINT)
- return FALSE;
-
- if(!ms_bHidden)
- {
- ShowWindow(SW_HIDE);
- ms_bHidden=TRUE;
- }
- lpps = (LPPAINTSTRUCT)lParam;
- if(ms_bBitmap)
- BLDDrawBkgndBitmap(GetParent()->GetSafeHwnd(),lpps,ms_szBitmap,GetDlgCtrlID(),ms_bStretch,TRUE,0,0);
- else
- BLDDrawBkgndIcon(GetParent()->GetSafeHwnd(),lpps,ms_szBitmap,GetDlgCtrlID());
- return TRUE;
- }
-
-
-
- IMPLEMENT_DYNCREATE(CSimGraphicButton, CButton)
-
- BEGIN_MESSAGE_MAP(CSimGraphicButton, CButton)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-